If you check back the archives you will see I have reported quite a few issues with large datasets and treeviews.   I have been promising a pygtk wrapper around the treeview that provides better performance + I am nearly there.   I've attached my code, there is quite a bit more I intend to do to it, but given your message I thought it worth posting now.

I think with a little work you could get good performance for your particular problem using this approach.

From the docstring at the top of the code:

An easy to use PyGTK grid that performs well with very large datasets.

Supports sorting and filtering of data.

The gtk treeview is a very powerful widget, but has serious performance issues
as the number of rows in the store grows.  Sorted and Filtered stores can cause
significant bottlenecks.

For very large datasets, just loading the data into the store can be a problem.

In some cases you might have very large tables that a user might want
to browse.  For instance, you might be using PyTables:

http://pytables.sourceforge.net/html/WelcomePage.html

Whilst you can create your own custom store to avoid having to read
the data into memory, as soon as you attach this store to a view the
view sets up a gtkrbtree for as many elements as your store says it has :(

EasyGrid works around this by using a small ListStore as a buffer between the
view and your actual data.  The View is embedded in a ScrolledWindow, with the
vertical scrollbar hidden.  A separate vertical scrollbar is used to show the actual
position in your data.

There is lots of hacking to intercept various events and make the
whole thing just about work.


TODO:
1. Tidy things up, remove debugging debris
2. Get the sorting working, support reverse.
3. Get filtering working nicely.
4. Get the API for data objects worked out so users don't have to provide any more
   sorting or filtering code than absolutely necessary.
5. Make auto_setup much smarter, allow it to be fed formatting hints.
6. Support a data object where the data is a list of dictionaries.
7. Have an automatic option for the vertical scrollbar.
8. Anything else I can think of.


I hope to get some of this fixed up in the not too distant future.

John

Jon Ellis wrote:
[pygtk] TreeView Sort Performance

I am having a problem when inserting a large amount of data into a tree
with a sorted column.  It seems that when the data is inserted in random
order, the inserts get exponentially slower.  I suspect this is because
the entire tree is getting resorted upon every insert.

However, if the data is inserted in sorted order, the inserts are
significantly faster.  When I put all of the random data into a list,
sort the list, then insert the data in sorted order it seems to take
about 1/10th of the time to do 10,000 inserts compared to inserting it
unsorted (see attached sample).  The only problem is that this is not a
reasonable solution for what I need to do.

Is it possible to keep the tree from sorting on each insert and just do
it once when I am done inserting?  Or is there a better way to do this
all together?  Any help would be appreciated!

--
Jon Ellis <[EMAIL PROTECTED]>


import gtk, time

#------------------------------------------------------------------------------
class TableTest:
    #--------------------------------------------------------------------------
    def __init__(self):
        window = gtk.Window()
        window.connect('destroy', self._onWindowDestroy)
        window.set_default_size(400, 100)

        self.table = gtk.Table(rows=2, columns=1)
        self.table.set_border_width(10)

        self.entry = gtk.HBox()
        entry = gtk.Entry()
        self.entry.pack_start(entry)
        entry.show()
        self.table.attach(self.entry, 0, 1, 0, 1, yoptions=gtk.SHRINK)
        self.entry.show()

        self.Testing = self.entry

        button = gtk.Button(label="Click Me!")
        button.connect('clicked', self._onButtonClicked)
        self.table.attach(button, 0, 1, 1, 2, yoptions=gtk.SHRINK)
        button.show()

        window.add(self.table)
        self.table.show()


        window.show()

    #--------------------------------------------------------------------------
    def _onButtonClicked(self, *args):
        self.entry.hide()
        #self.entry.destroy()

        self.entry = gtk.HBox()
        button = gtk.Button()
        image = gtk.image_new_from_stock(gtk.STOCK_SAVE, gtk.ICON_SIZE_LARGE_TOOLBAR)
        button.add(image)
        image.show()
        button.show()
        self.entry.pack_start(button)
        self.entry.set_border_width(10)
        self.table.attach(self.entry, 0, 1, 0, 1, yoptions=gtk.SHRINK, xoptions=gtk.SHRINK)
        self.entry.show()
        while gtk.events_pending():
            gtk.main_iteration()
        time.sleep(3)

        self.entry.hide()
        #self.entry.destroy()

        self.entry = gtk.Entry()
        self.table.attach(self.entry, 0, 1, 0, 1, yoptions=gtk.SHRINK, xoptions=gtk.SHRINK)

        self.entry.show()
        
        

    #--------------------------------------------------------------------------
    def _onWindowDestroy(self, *args):
        gtk.main_quit()

#------------------------------------------------------------------------------

if __name__ == '__main__':
    test = TableTest()
    gtk.main()
  

_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Attachment: easygrid.py
Description: application/python

_______________________________________________
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