[wxPython-users] wxGrid performance
Paul McNett
p at ulmcnett.com
Mon Oct 1 10:48:08 PDT 2007
Jeff Peery wrote:
> Hello, I'm using a wxgrid in my application and it seems to get very
> slow in I have more than 1000 cells. most of the problems occurs when I
> set the background color of cells, using SetCellBackgroundColor(). If I
> don't set the background color the grid performs much quicker (I can
> scoll through the spreadsheet without have to wait for it to refresh).
> Is there a better way to set the background color so it won't cause the
> grid to be so slow?
>
> Also to set the cell data I iterate through all the data points and use
> SetCellValue() to set the cell data. I also use SetRowLabelValue() to
> set the row label. For datasets that are large (in the thousands) this
> is too slow to redraw. Is there a quicker way to draw the spreadsheet?
> Thanks.
You can get lightning-fast grid performance if you implement it in a
virtual fashion. Going virtual means you never iterate your data points.
Instead, you configure the grid and the underlying data table to only
look up and return the data the grid asks for. You do this in the
GetValue() method of the grid's table.
See the wxPython demo - I think it is call GridMegaWidget or something
like that.
You can use similar techniques for the cell background color.
If your data is coming from a database like SQLite, MySQL, or the like,
you may wish to take a look at Dabo: our dGrid handles all the complex
bits underneath, leaving a nice clean API for you to deal with for
displaying records and fields from a data cursor. However, if what you
want is a spreadsheet, that may have arbitrary cell content not related
to an underlying data cursor, our grid is probably not suitable for your
needs.
HTH
--
pkm ~ http://paulmcnett.com
More information about the wxpython-users
mailing list