[pygtk] gtk.ListStore columns in a gtk.ComboBox

Isaac Alston genelisp at googlemail.com
Tue Jun 24 15:27:38 WST 2008


2008/6/23 BJörn Lindqvist <bjourne at gmail.com>:
> I think the combo box you get from the widget tree already has a cell
> renderer text that renders the first column in the list store. If so,
> you could just change the column that the renderer will render:
>
> combo.set_attribute(combo.get_cells()[0], text, 1)

This works! Thank you! It's add_attribute though, but that's irrelevant.
I'm not sure why it already had a CellRendererText, because I haven't
specified one - perhaps glade adds it in automatically.

Now, in this section, for some reason set_active no longer works. The field
is displayed correctly but nothing is selected to begin with (the ComboBox
looks like it's empty until you click on it).

for a, b in [(0, 'search_combo_1'), (1,'search_combo_2')]:
    combo = self.wTree.get_widget(b)
    combo.add_attribute(combo.get_cells()[0], 'text', 1)
    combo.set_model(self.search_lstore)
    combo.set_active(a)

I tried just combo.set_active(0) as well, and it didn't work...

Thanks for the help so far.

-- 
Isaac


More information about the pygtk mailing list