Pygtk : Destroying Combobox Causes Error
My aim is to destroy a combobox if one of its items is active. I wrote this test code : import pygtk pygtk.require('2.0') import gtk import gobject def remove(combobox): if 'Opt
Solution 1:
It comes because you use a liststore.
New gtk code should now use combo_box_new_text()
here is your code working :
for i in range(nb):
combo = gtk.combo_box_new_text()
cell = gtk.CellRendererText()
combo.pack_start(cell, True)
combo.add_attribute(cell, 'text', 0)
for text in ["OptionA-%d"%(i+1), "OptionB-%d"%(i+1), "OptionC-%d"%(i+1)]:
combo.append_text(text)
combo.set_active(0)
combo.connect("changed", remove)
main_box.pack_start(combo, expand=False)
window.show_all()
gtk.main()
Solution 2:
Your code is solid, the widgets are destroyed like they should be. Just write it off as an oddity of pygtk/PyGObject's memory management.
Solution 3:
So why are you not using
combobox.hide()
instead of
combobox.destroy()
It seems destroying individual widgets is not really the thing you should do. In most cases I do not destroy Gtk widgets, since later you may wish to show them again.
Post a Comment for "Pygtk : Destroying Combobox Causes Error"