[pygtk] How to add items to an empty ComboBox / ComboBoxEntry ( created with glade) ?
Frédéric
frederic.mantegazza at gbiloba.org
Mon Sep 22 01:05:38 WST 2008
On dimanche 21 septembre 2008, Mats Taraldsvik wrote:
> Dear list,
>
> I'm creating an application with pyGTK and Glade. In this I want to
> populate a combobox(2) depending on the selected item in another
> combobox(1).
>
> Usually, I add None as an item of the comboboxes in glade, because
> nothing happens when I try to add items to an empty combobox. However,
> since I have to repopulate a combobox(2), I need the proper solution,
> since I have to empty it depending on combobox(1).
Here is what I do to dynamically populate a combobox:
presetTemplateCombobox = self.wTree.get_widget("presetTemplateCombobox")
listStore = gtk.ListStore(gobject.TYPE_STRING)
presetTemplateCombobox.set_model(listStore)
cell = gtk.CellRendererText()
presetTemplateCombobox.pack_start(cell, True)
#presetTemplateCombobox.add_attribute(cell, 'text', 0)
presetTemplateCombobox.append_text("blablabla")
...
Note that if I use the add_attribute() method, I get the entries twice on
each line... Don't know why.
--
Frédéric
http://www.gbiloba.org
More information about the pygtk
mailing list