Greg Aumann wrote:
I am pretty new to PyGTK and am having some trouble trying to get a
comboboxentry with multiple columns in it.
I am using glade 2.6.7, pygtk 2.4.1 on Gentoo linux
I am trying to rewrite an Access database GUI in pygtk. In Access I have
a combobox that has multiple columns, including one with the primary key
that is hidden. I select the entry using the combobox and jump to the
entry with that primary key. I would like to do something similar with
pygtk.
As the ComboBoxEntry widget is reasonably new I am finding it difficult
to find more complex examples of how to use it. I am already using John
Finlay's tutorial and reference.
I am trying to use a ComboBoxEntry with a multiple column liststore. It
is partially working. I can load all the columns into the list store but
I can only display one at a time. Is there anyway to display multiple
columns? Or should I be using a TreeStore?
The ComboBoxEntry is created by glade. Then I use the following code:
combo_widget = widgets.get_widget('comboboxentry')
liststore = gtk.ListStore(str, str, str, str)
for r in rows:
liststore.append(r)
combo.set_model(liststore)
combo.set_text_column(1)
You can pack more cell renderers into the comboboxentry for display in
the popdown menu by using the CellLayout pack_start() method and then
set the attributes using the set_attributes() or add_attribute() methods:
cell = gtk.CellRendererText()
combo.pack_start(cell)
combo.add_attribute(cell, 'text', 2)
Repeat as needed :-)
John
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/