On Sat, 2005-01-15 at 15:27 +0100, Nemesis wrote:
> On Fri, 14 Jan 2005 11:31:17 +0000
> "Gustavo J. A. M. Carneiro" <[EMAIL PROTECTED]> wrote:
> 
> > > f=open("list.dat","rb")
> > > list=cPickle.load(f)
> > > f.close()
> > > for item in list:
> > >     model.append(item)
> > > 
> > > This algorithm is very slow it takes about ten minutes on my
> > > [EMAIL PROTECTED] I also used the "fixed-height-mode" but nothing
> > > changed.
> > > 
> > > Is there a way to improve the speed of this operation?
> > 
> >   Try using a GenericTreeModel (see pygtk examples), 
> 
> I tried with this solution:
> 
> ------------------------Code Snippet----------------------------------
> 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 self.list[path[0]]
>         
>     def on_get_path(self, rowref):
>         return self.list.index(rowref)
>         
>     def on_get_value(self, rowref, column):
>         return rowref[column]
>         
>     def on_iter_next(self, rowref):
>         try:
>             i = self.list.index(rowref)+1
>             return self.list[i]
>         except IndexError:
>             return None
> 
>     def on_iter_children(self, parent):
>         return None
> 
>     def on_iter_has_child(self, rowref):
>         return False
>         
>     def on_iter_n_children(self, rowref):
>         return 0
>         
>     def on_iter_nth_child(self, parent, n):
>         return None
>         
>     def on_iter_parent(self, child):
>         return None
> ------------------------Code Snippet----------------------------------
> 
> But it is much slower than the ListStore solution :-/

  Even with fixed-height-mode turned on?  I was thinking that if
TreeView would only ask for the items that fit in view, then you'd need
to get less than 100 items at a time, instead of 400000, hence the speed
improvement.

  So, something must be failing.  I see you defined on_iter_n_children
to always return 0.  Are you sure about this?!

> 
> 
> > or  TreeViewColumn.set_cell_data_func().
> 
> I can't figure how to use set_cell_data_func for this purpose
> 

_______________________________________________
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