Anes_P_A
March 3rd, 2016, 12:13 PM
Dear Friends,
I am using PyGtk for my project. I have a dialog with some combobox listing . Currently it work with an Ok & Cancel button. My requirement is I need to remove the OK and Cancel button and in onchange of Combobox items need to submit that value and automatically close the
dialog without any manual intervention.
My current code is
def mostrar_combobox(self, titulo, texto_etiqueta, lista):
"""
MÃ © All to show a combobox on screen and get the option chosen
"""
#print texto_etiqueta
#dialogo = gtk.Dialog(titulo, None, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
dialogo = gtk.Dialog(titulo, None, gtk.DIALOG_MODAL, None)
dialogo.connect('response', lambda *x: self.destroy())
etiqueta = gtk.Label(texto_etiqueta)
etiqueta.show()
dialogo.vbox.pack_start(etiqueta)
combobox = gtk.combo_box_new_text()
for x in lista:
combobox.append_text(x)
combobox.connect('changed', self.changed_cb)
combobox.show()
dialogo.vbox.pack_start(combobox, False)
response = dialogo.run()
combobox.connect('changed', self.changed_cb)
dialogo.emit("delete-event", gtk.gdk.Event(gtk.gdk.DELETE))
elemento_activo = combobox.get_active()
return elemento_activo
def changed_cb(self, combobox):
index = combobox.get_active()
if index > -1:
print index
My application dialog preview is :
267611
Waiting for fast reply
Thanks
Anes
I am using PyGtk for my project. I have a dialog with some combobox listing . Currently it work with an Ok & Cancel button. My requirement is I need to remove the OK and Cancel button and in onchange of Combobox items need to submit that value and automatically close the
dialog without any manual intervention.
My current code is
def mostrar_combobox(self, titulo, texto_etiqueta, lista):
"""
MÃ © All to show a combobox on screen and get the option chosen
"""
#print texto_etiqueta
#dialogo = gtk.Dialog(titulo, None, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
dialogo = gtk.Dialog(titulo, None, gtk.DIALOG_MODAL, None)
dialogo.connect('response', lambda *x: self.destroy())
etiqueta = gtk.Label(texto_etiqueta)
etiqueta.show()
dialogo.vbox.pack_start(etiqueta)
combobox = gtk.combo_box_new_text()
for x in lista:
combobox.append_text(x)
combobox.connect('changed', self.changed_cb)
combobox.show()
dialogo.vbox.pack_start(combobox, False)
response = dialogo.run()
combobox.connect('changed', self.changed_cb)
dialogo.emit("delete-event", gtk.gdk.Event(gtk.gdk.DELETE))
elemento_activo = combobox.get_active()
return elemento_activo
def changed_cb(self, combobox):
index = combobox.get_active()
if index > -1:
print index
My application dialog preview is :
267611
Waiting for fast reply
Thanks
Anes