[pygtk] gtk.ListStore columns in a gtk.ComboBox (added full code
listing)
Alessandro Dentella
sandro at e-den.it
Mon Jun 23 04:42:27 WST 2008
> future. So my question remains: how can I display a single column from
> a multi-column ListStore in a ComboBox?
I've never tryed in a ComboBox. I just guess is not very different than an
Entry. I paste here some code I have worked out in the past. the code is
working but I had to cut many parts that would be useless. I hope I didn't
cut too much.
The key point is that you create
a completion object
a renderer
a liststore
The renderer knows that it should represent what is stored in one column of
the liststore, while you instruct the completion to use the other via
set_match_function.
entry = gtk.Entry()
completion = gtk.EntryCompletion()
completion.set_property('popup-set-width', True)
completion.set_property('minimum-key-length', 0)
completion.connect('match-selected', self.match_selected_cb, field_name)
listore = gtk.ListStore(int, str)
renderer = gtk.CellRendererText()
completion.pack_start(renderer)
completion.add_attribute(renderer, 'text', 1)
completion.set_match_func(self.match_func, (col_entry, mode))
completion.set_model(listore)
entry.set_completion(completion)
Hope that helps
sandro
*:-)
More information about the pygtk
mailing list