[pygtk] gtk.ListStore columns in a gtk.ComboBox
BJörn Lindqvist
bjourne at gmail.com
Tue Jun 24 05:57:10 WST 2008
On Sun, Jun 22, 2008 at 4:09 PM, Isaac Alston <genelisp at googlemail.com> wrote:
> I am making a search function where users can select two fields which
> they'd like to search on in a database. I'm having trouble displaying
> a single column from a gtk.ListStore with multiple columns in a
> gtk.ComboBox correctly. I have two columns in my ListStore: 'id' and
> 'field'. 'field' holds text like 'Artist' and 'Name'. I have an id so
> I can compare their selection easily - I do not want to compare names
> like 'Artist' and 'Name' in the code, especially as they will be
> i18ned too. I've tried getting the ComboBox to display only the second
> column with add_attribute, but it seems to add the 'id' column by
> default and displays both the id and field side-by-side. How do I stop
> this so that it only shows the 'field' column?
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)
--
mvh Björn
More information about the pygtk
mailing list