I disabled sorting while doing the appends is happening, but it's still
slow. Maybe some calls in my
code must be in a different order..

Have a look:

    # create a liststore with one string column to use as the model
    liststore = gtk.ListStore(str, int)
    liststore.set_default_sort_func(None)
    # create the TreeView using liststore
    treeview = gtk.TreeView(liststore)
    treeview.set_size_request(300, 200)
    treeview.set_reorderable(False)
    treeview.connect('row-activated', self.selectItem, object_list)
    # create a CellRenderer to render the data
    cell = gtk.CellRendererText()
    # create the TreeViewColumns to display the data
    column = gtk.TreeViewColumn('List of Objects (identifiers)', cell,
text=0)
    # column.set_sort_column_id(0)
    treeview.append_column(column)
    # freeze the tree and detach the model to add some rows...
    treeview.freeze_child_notify()
    treeview.set_model(None)
    # Add the items to the liststore
    i=0
    rows=[]
    for row in object_list)):
        liststore.append( [row.identifier,  i])
        i+=1
    treeview.set_model(liststore)
    treeview.thaw_child_notify()
    treeview.show()
    # make a scrolled window container to pack th treeview,
    # so tha it supports scolling
    scrolledwindow = gtk.ScrolledWindow()
    scrolledwindow.add(treeview)
    hbox.pack_start(scrolledwindow, False, 5, 5)
-------------------------------------------------------------------------------------------------------------
object_list is a list that contains some objects with some attributes..

Thank you,
Thanasis

On Wed, Oct 28, 2009 at 5:20 PM, Neil Muller
<drnlmuller+...@gmail.com<drnlmuller%2b...@gmail.com>
> wrote:

> On Wed, Oct 28, 2009 at 4:33 PM, Petsas Athanasios <pet...@csd.uoc.gr>
> wrote:
> > Hello,
> >
> > I have one more question on the use of the treeview with a listStore
> model.
> > When I want to append a big amount of rows, for instance 100, the appeend
> > method it is extremely slow inside a loop..
> >
> > I tried to use this code:
> >
> > treeview.freeze_child_notify()
> > treeview.set_model(None)
> >
> > # Add rows to the model
> > # ...
> >
> > treeview.set_model(model)
> > treeview.thaw_child_notify()
> >
> > from taken from this page:
> > http://faq.pygtk.org/index.py?req=show&file=faq13.043.htp
> > but it's still slow!
>
> Appendiing 100 rows should be fast. The only thing I can think of that
> would make this noticeably slow is if the ListStore is sorted, in
> which case you should disable sorting while doing the appends.
>
> --
> Neil Muller
> drnlmul...@gmail.com
>
> I've got a gmail account. Why haven't I become cool?
>
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to