[pygtk] TreeView/CellRenderText and numbers

Dieter Verfaillie dieterv at optionexplicit.be
Wed Oct 12 18:09:05 WST 2011


On Wed, 12 Oct 2011 11:29:59 +0200, Olaf Devik wrote:
> I am struggling with TreeView and CellRendererText.
>
> I have a ListStore containing a number of fields with strings and
> integers. The ListStore is connected to a TreeView and the string
> fields render well as expected, but the fields with integers will not
> render.
>
> How can I render integer values in the TreeView?

Exactly like you would render a string value from your model. For
example, assuming field 1 in your model is of type int:

cell = gtk.CellRendererText()
intcolumn = gtk.TreeViewColumn('Amount')
intcolumn.pack_start(cell, True)
intcolumn.add_attribute(cell, 'text', 1)

A complete and working example is attached.

mvg,
Dieter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: treeview_columns.py
Type: application/python
Size: 1730 bytes
Desc: not available
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20111012/3e3814b1/attachment.bin>


More information about the pygtk mailing list