Recently I have been using the new GtkTreeView control often in my
programs, and have been hitting problems in their use in PyGTK 1.99.
Basically the majority of the issues resolve down to the fact that PyGTK
wraps a GtkTreeIter and gives any Python code a tuple of indices
instead. This looks like a nice clean solution (and is for the most
part) but leads to problems.
For example: assuming the tree model (self.model) is a GtkListStore and
the GtkTreeView is self.view, the following code should remove the
selected rows from the model and update the view:
selection = self.view.get_selection()
selection.selected_foreach(lambda iter: self.model.remove(iter))
Nice clean code (thanks jrb :) , which unfortunately does not work in
PyGTK as the variable "iter" is not a GtkTreeIter (as it would be in C)
but a tuple of indicies. GtkListStore.remove() expects a GtkTreeIter
and so complains.
Clearly some work is needed here -- GtkTreeView et al are a very
powerful set of objects and are crippled at the moment. I can see
several solutions:
1) carry on GtkTreeIters being passed as tuples and provide functions
which will create a GtkTreeIter based on a tuple.
2) pass GtkTreeIters to Python code but add accessor functions to
retrieve the iterator as a useful value (such as a tuple as now).
I'm in favour of (2) as it means that intensive GtkTreeView code is very
clean -- the API is very rich and allows most operations to be performed
trivially (see the above lambda function for an example).
Hope this can be sorted soon...
Regards,
Ross Burton
--
Ross Burton mail: [EMAIL PROTECTED]
jabber: [EMAIL PROTECTED]
diary: http://advogato.org/person/RossBurton
PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/