I'm trying to implement a drop down list in an Ubuntu app using Glade (GTK+3) and Python. I can get the ComboBoxText to display, populated with strings. However when I close the window it is contained in and then re-open it, the combobox is not there, just a completely blank window.
I added the ComboBoxText widget in question to a window in Glade. I then added this code in my Python programme:
def on_button_edit_clicked(self, widget):
""" display list of events already stored, and allow deletion """
self.combo = self.builder.get_object('combo_box')
self.store = Gtk.ListStore(str)
self.store.append(['hello'])
self.store.append(['goodbye'])
self.combo.set_model(self.store)
event_editor = self.builder.get_object("event_editor")
event_editor.show()
I even tried destroying the widget to see if that helps:
def on_event_editor_destroy(self, widget):
self.combo.destroy()
self.store = Gtk.ListStore(str)
self.combo.set_model(self.store)
EDIT:
I have since tried some alternative code, that included a CellRendererText object, but still no luck.
These are my sources: I created a Gtk.ListStore(), then I created a Gtk.CellRendererText(), then I created a Gtk.ComboBox(). This was all in-line with example 13.3 here.
Nothing works. When I open the combobox window a 2nd time, it is just a blank window. Can anyone help please?
I've found a solution. I was closing the window using the x button, which must have been destroying the widget and it's associated list store. Instead I am now using a custom button that merely hides the window.