[pygtk] CellRendererCombo Question
John Finlay
finlay at moeraki.com
Thu Mar 9 15:17:10 WST 2006
Hussein Vastani wrote:
> Hello All,
> Does anyone know if something like the wrap_width function is implemented for
> the CellRendererCombo in pygtk?
> Heres the scenario.
> I populate my combobox (in my treeview) dynamically and want to display it in
> more than one column if the list is large.
>
> This is how I set it up :
>
> model = gtk.Liststore(str)
> tree_store_col = 0
> cell_renderer = gtk.CellRendererCombo()
> cell_renderer.set_property("model",model)
> cell_renderer.set_property('text-column', 0)
> cell_renderer.set_property('editable', True)
> new_col = gtk.TreeViewColumn(col_name, cell_renderer, text=tree_store_col)
> tree.append_column(new_col)
> cell_renderer.connect('editing-started', populate_combo, (tree_store,))
>
> And this is how I populate the combobox in the populate_combo callback
> def populate_combo(self, cell, editable, path, data):
> store = data[0]
> iter = store.get_iter(path)
> items = self.get_list() # my function get_list() returns a list of strings
> m = cell.get_property('model')
> m.clear()
> items.sort()
> for s in items:
> m.append([s])
>
> so if my items list is large, it gets frustrating to scroll the entire list to
> get to the required item. It would be nice if the items were displayed in more
> than one column (for eg.)
> Any suggestions on how to make this better?
>
In populate_combo() the ComboBox is the "editable" param so
editable.set_wrap_width(width) should allow you to display the items in
multiple columns.
John
More information about the pygtk
mailing list