[pygtk] GtkCTree Doesn't Work

Aaron Optimizer Digulla digulla@hepe.com
Mon, 18 Sep 2000 11:16:12 +0200


On Mon, Sep 18, 2000 at 02:36:10AM -0500, Eric Gillespie, Jr. wrote:

> With Gnome-Python 1.0.53 from Debian unstable, i can't seem to
> attach any data to a row in a CTree. I don't know of any other
> way to find what the user selected. Even if i were to catch the
> selection signal, i would still have the same problem of mapping
> the node to useful data. Am i missing something obvious?
> 
> Anyway, i've attached a small program demonstrating the problem.
> The error message i get is below.
> 
> Traceback (innermost last):
>   File "hey.py", line 11, in ?
>     ctree.set_row_data(node, "hey")
>   File "/usr/lib/python1.5/site-packages/gtk.py", line 1278, in set_row_data
>     _gtk.gtk_clist_set_row_data(self._o, row, data)
> TypeError: illegal argument type for built-in operation

To get the current selection, try ctree.selection (it's an attribute,
not a method).

And there is a bug in 0.6.6: node_set_cell_style() and
node_get_cell_style() call _gtk.gtk_ctree_node_[sg]et_row_style()
instead of ...cell_style(). James, can you fix it, please ?

In the meantime, everyone else can use this code as a workaround:

# Bugfix in pygtk
import _gtk
def node_set_cell_style(self, node, col, style):
    return _gtk.gtk_ctree_node_set_cell_style(self._o, node, col, style)
def node_get_cell_style(self, node, col):
    return _gtk.gtk_ctree_node_get_cell_style(self._o, node, col)
GtkCTree.node_set_cell_style = node_set_cell_style
GtkCTree.node_get_cell_style = node_get_cell_style

Python is great :-)

-- 
==============================================
Sowatec AG,       CH-8330 Pfäffikon (ZH)
Witzbergstr. 7,   http://www.sowatec.com
Tel: +41-(0)1-952 55 55
Fax: +41-(0)1-952 55 66
----------------------------------------------
Aaron "Optimizer" Digulla, digulla@sowatec.com
==============================================