ComboBoxText in Glade / GTK+3 / Python

Post here if you need help with creating a Graphical User Interface in Python.

ComboBoxText in Glade / GTK+3 / Python

Postby UbuntuJon » Tue Apr 16, 2013 11:22 am

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') = Gtk.ListStore(str)['hello'])['goodbye'])

event_editor = self.builder.get_object("event_editor")

I even tried destroying the widget to see if that helps:

def on_event_editor_destroy(self, widget):
self.combo.destroy() = Gtk.ListStore(str)


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?
Posts: 2
Joined: Tue Apr 16, 2013 11:15 am

Re: ComboBoxText in Glade / GTK+3 / Python

Postby micseydel » Tue Apr 16, 2013 5:50 pm

Hello, and welcome to the forum! I'm not a GUI guy, so I can't help directly with your problem, but I recommend you read this to help you get better help from those who could.
Join the #python-forum IRC channel on for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from :)
User avatar
Posts: 2905
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: ComboBoxText in Glade / GTK+3 / Python

Postby Yoriz » Tue Apr 16, 2013 7:34 pm

I don't know that gui library but in wxpython if you close a window all of its child controls are destroyed.
If you wanted to use the same window and its controls again rather then closing the window you could hide the window and then show it again when it was required.
If you didn't want to reuse the same window you would have to create a new instance of the window.
New Users, Read This
Join the #python-forum IRC channel on!
User avatar
Posts: 1628
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: ComboBoxText in Glade / GTK+3 / Python

Postby UbuntuJon » Tue Apr 16, 2013 9:20 pm

Hi Yoriz

Thanks so much. I didn't think of that! I've removed the "close window" default button, and added a custom one, that just hides the window.

Posts: 2
Joined: Tue Apr 16, 2013 11:15 am

Return to GUI

Who is online

Users browsing this forum: No registered users and 5 guests