I'm using pygtk-1.99.10, compiled against the most recent GARNOME
releasea RH7.2 Linux system.  I have some questions about the
TreeView/Model widgets and interfaces.

1) I have a TreeView widget based on a ListStore model that allows two
of the columns to be edited (not in place; using other widgets that copy
changes to the model) when a row is selected.  If the row is unselected,
I want to delete any rows in which either of the columns is empty.  Here
is the code from my treeview_selection_changed handler:

        def lm_cleanup_foreach(lm, path, citer):
            t = lm.get_value(iter, PERSON_COL)
            if not t:
                lm.remove(citer)
                return gtk.TRUE
            t = lm.get_value(iter, PERSON_SCORE_COL)
            if not int(t):
                lm.remove(citer)
                return gtk.TRUE
        self.person_lm.foreach(lm_cleanup_foreach)

(There is other code in the handler, but it just loads values into a
couple of widgets based on the selection.)

When I run the program and set the values in a row to empty, then select
a different row, sometimes it seems to work fine, sometimes the program
stops accepting input without any sort of message (but it can still be
killed), and sometimes it gives the message:

Traceback (most recent call last):
  File "./newchar.py", line 421, in person_sel_changed
    self.person_lm.foreach(lm_cleanup_foreach)
  File "./newchar.py", line 413, in lm_cleanup_foreach
    t = lm.get_value(iter, PERSON_COL)
TypeError: iter must be a GtkTreeIter

Gtk-ERROR **: file gtkrbtree.c: line 1044
(_gtk_rbtree_node_find_offset): assertion failed: (node->left)
aborting...

It seems I'm hosing some internal structure by removing a row within the
selection handler.  Any more specfic diagnoses, and/or suggestions for a
fix or workaround?

2) Perhaps a corollary to the above: Which functions modify TreeIters in
place.  In general, it seems that most of the pygtk functions pass
TreeIters back as return values as compare to their C counterparts, but
I was surprised to find the tree walking functions (like iter_next)
modify their argument in place.

3) How do you set the horizontal alignment of a column (not just the
header)?  I know CellRenderers have an xalign attribute, but I having
figure out how to set it.

4) How robust is the TreeModel interface for subclassing?  Reading the
archives suggests that it can be done, but that it has some warts.  Is
it practical to construct Python classes that implement the TreeModel
interfaces as opposed to shuttling data back and forth between my data
structures and a TreeStore or ListStore?

5) I'm sure this is low priority, but has any thought been given to
giving TreeModel a more python-y interface; e.g. something more
mapping-like using strings instead of ints as column keys?

I know this is a lot; it is the collected concerns of about three days
of coding and groping for answers on my own.  Any help would be
appreciated.  Thanks.

Jay


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to