On Sat, 15 Jan 2005 19:12:20 +0100
Nemesis <[EMAIL PROTECTED]> wrote:
OK I found a solution!
I changed a little bit the code, now I use as iter the index in the
list, in the first version a was using as iter the row itself, now the
code is faster, also faster than ListStore.
Here is the new code:
class Custom_List(gtk.GenericTreeModel):
def __init__(self,list=[]):
gtk.GenericTreeModel.__init__(self)
self.list=list
def on_get_flags(self):
return gtk.TREE_MODEL_LIST_ONLY|gtk.TREE_MODEL_ITERS_PERSIST
def on_get_n_columns(self):
return 2
def on_get_column_type(self, index):
return gobject.TYPE_STRING
def on_get_iter(self, path):
return path[0]
def on_get_path(self, rowref):
return tuple(rowref)
def on_get_value(self, rowref, column):
try:
return self.list[rowref][column]
except IndexError:
return None
def on_iter_next(self, rowref):
try:
self.list[rowref+1]
except IndexError:
return None
else:
return rowref+1
def on_iter_children(self, parent):
return None
def on_iter_has_child(self, rowref):
return False
def on_iter_n_children(self, rowref):
if rowref:
return 0
return len(self.list)
def on_iter_nth_child(self, parent, n):
if parent:
return None
try:
self.list[n]
except IndexError:
return None
else:
return n
def on_iter_parent(self, child):
return None
--
|\ | |HomePage : http://nem01.altervista.org
| \|emesis |XPN (my nr): http://xpn.altervista.org
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/