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 :-/


> or  TreeViewColumn.set_cell_data_func().

I can't figure how to use set_cell_data_func for this purpose

-- 
 
 |\ |       |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/

Reply via email to