Andrew Burr wrote:
>All,
>
>I am trying to make sort function for my GtkTreeView...
>
>...
>store.set_sort_func(1, my_sort_func)
>...
>
>def my_sort_func (store, a, b):
> model = ??
> model.get(b, 0, bb, -1)
> model.get(b, 0, bb, -1)
> return strcasecmp(aa, bb)
>
>My question is how do I get the model in my_sort_func, so I can get the
>data from the iter? It seems like the C version gives you the model, but
>the python bindings give you a gtk.ListStore object instead. Help.
>
>
A GtkListStore is an implementation of GtkTreeModel, so you can replace
"??" with "store". The function should probably look like this:
def my_sort_func(model, a, b):
aa = model.get_value(a, 0)
bb = model.get_value(b, 0)
return locale.strcoll(aa, bb)
(you probably want to do strcoll() rather than strcasecmp(), as it will
do a locale dependent sort).
James.
--
Email: [EMAIL PROTECTED] | Linux.conf.au 2003 Call for Papers out
WWW: http://www.daa.com.au/~james/ | http://conf.linux.org.au/cfp.html
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/