The problem with the code you are referring to above seems to be that the ComboBox
actually only has 1 element when you start editing, which makes drop-down feature useless (and hence inactive). To make it behave as I suspect you wish, all you have to do is use another signal to execute self.populate_combo
. I added two lines after the treeview was created to make it work:
treeview = gtk.TreeView(liststore_hardware)
sel = treeview.get_selection()
sel.connect("changed", self.populate_combo)
That is, I made the changed selection cause population of the Combos, which implied that they had more than one element in them when control was returned to the main-loop. And hence drop-down worked.
I also commented out the previous editing-started
signal since it added nothing with the current structure of the program.
window.connect("destroy", lambda w: gtk.main_quit())
#self.cellrenderer_combo.connect("editing-started", self.populate_combo)
self.cellrenderer_combo.connect("edited", self.combo_changed, liststore_hardware)
Edit:
On second thought, the model is a None
after __init__
has been run and not 1-length per row as I wrote above, which makes the lack of dropdown-features even more reasonable.
Comment:
The code you referred to and my change to it are both only rational if changing rows (or editing) causes a drastic need to rewrite the ListStore
. I'm not really sure what type of scenario would demand that. If, on the other hand, the contents of the TreeView
and the ComoBox
' ListStore
varies as a result of a search-action or filtering done else-where, then that search, rather than the change of rows should invoke populate_combo
.
So an alternative solution in the scope of the code at hand, my suggested event above can also be commented out and a simple
self.populate_combo()
be added as the last line of the init
function.
Further, should there be a need to re-populate the combos during the run of the app, I would suggest that the current ListStore
is modified rather than creating a new one each time, if the changes are not expected to be major (in which case make a new is probably fastest and simplest).