[pygtk] unexpected behaviour with gtk.ComboBox

Markus W. Barth markus at sismografo.es
Sun Jun 8 18:48:00 WST 2008


According to the docs both the constructor of gtk.ComboBox and 
gtk.Combobox.set_model() expect a gtk.TreeModel. However, if I use a custom 
model (derived from gtk.GenericTreeModel) I get some strange behaviour.
Instead of showing all rows of the Model it will only show repeatedly the 
value of the first row.

The model contains five rows with different values but the ComboBox will show 
five times the same value, which is the value of the first row.

<snippet>
        line_type_model = models.SqlListModel(model.LineType)
        line_type_model.refresh()
        self.line_type_combo = gtk.ComboBox(model=line_type_model)
        cell = gtk.CellRendererText()
        self.line_type_combo.pack_start(cell, True)
        self.line_type_combo.add_attribute(cell, 'text', 0)
        self.line_type_combo.show()
</snippet>

The same model works fine with a gtk.TreeView and
<snippet>
 for line in line_type_model:
            print line[0]
</snippet>
will print out nice and neatly the values to stout

Any idea what could be the reason?


More information about the pygtk mailing list