[pygtk] CellRenderToggle, ListStore and tri-state
Facundo Batista
facundobatista at gmail.com
Sat Apr 26 20:17:31 WST 2008
2008/4/26, Alessandro Dentella <sandro at e-den.it>:
> i want to improve an editor of database tables I'm working on. When
> editing tables I use a TreeView with a ListStore and I use a <GType
> gboolean> to store the data.
>
> I'd like to add capability to handle IS NULL beside True and False ad that
> is a different valuable choiche.
See, you need to define two bools in the TreeStore, one for thre real
True/False state, other for the Inconsistant state (I'm copying this
from an example, the complete code is here [1]).
treestore = gtk.TreeStore(str, gobject.TYPE_BOOLEAN,
gobject.TYPE_BOOLEAN, str, gtk.gdk.Pixbuf)
Then, when you define the column:
# create a TreeViewColumn for the checkbox
tvcolumn = gtk.TreeViewColumn('Active')
cell = gtk.CellRendererToggle()
cell.set_property('activatable', True)
cell.connect('toggled', self.activatePlugin)
tvcolumn.pack_start(cell, False)
tvcolumn.add_attribute(cell, 'active', 1)
tvcolumn.add_attribute(cell, 'inconsistent', 2)
self.append_column(tvcolumn)
Regards,
[1] http://w3af.svn.sourceforge.net/viewvc/w3af/branches/sasha/core/ui/gtkUi/pluginconfig.py
--
. Facundo
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
More information about the pygtk
mailing list