wxGrid performance

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.

Jeff

···

Shape Yahoo! in your own image. Join our Network Research Panel today!

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

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.

Use a table and provide the cell data and attributes from it "on-demand". Take a look at the "HUGE table" sample in the demo. It has 100 million cells, uses background colors, and is very fast.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!