[pygtk] CellRendererToggle: don't show the checked value

Maximiliano Robaina maxi_robaina at yahoo.com.ar
Thu Dec 27 03:07:05 WST 2007


Hi,
I've some problems using CellRendererToggle columns in a TreeList 
compenent. When I do click in the checkbox column, your value doesn't 
change visualy.
I will try to expose my scenario:

I've a class, for instance: Person. This class is "popuate" from a DB 
access framework (SQLAlchemy)

class Person(object):
    def __init__(self)
        self.selected = False

Then, I get a object list of Person class and with it, I want to 
populate my GtkTreeView. My model is a gtk.ListStore
Now, the "selected" attribute is used to implementing multiselect 
functionality. For this, "selected" field representing a CheckBok 
Column  in the  TreeView.

When I do click over the checkbox column, you state value don't change, 
but only visualy.
This is a piece of my code:

        if type is bool:
            cell = gtk.CellRendererToggle()
            cell.set_property('activatable', True)
            cell.connect('toggled', self._col_bool_click, self._store)
            col = gtk.TreeViewColumn('', cell)
            col.add_attribute(cell, 'active', columnId)
        else:
            cell = gtk.CellRendererText()
            col = gtk.TreeViewColumn('', cell, text=columnId)

.....

def _col_bool_click(self, cell, path, model):
        obj = model[path][0]
        obj.selected = not obj.selected  


Why the checked value don't change in my screen over the TreeView column ?

Thank in advance.

P.D.: Sorry, my english is very bad. I hope be clear.








More information about the pygtk mailing list