Grid update problem

Kartic Krish wrote:

Michele,

Like Horst mentioned, please take a look at Grid_MegaExample.py.

I too use a grid modelled after Grid_MegaExample and it works without
delays (just the vanilla version, adding attributes is another ball game). If you could post your code, I can take a look at it and let you know, in my limited experience, what you can do to make it
faster.

That grid is the application heart, so for post it I have to post all
the app :), but I can recreate the problem with this:

import wx, random
import wx.grid

class Frame1(wx.Frame):
     def __init__(self, parent):
         wx.Frame.__init__(self, parent, size=wx.Size(800,600))

         sz = wx.BoxSizer(wx.VERTICAL)
         b1 = wx.Button(self, label='button1')
         self.gr = wx.grid.Grid(self)
         self.cols, self.rows = 10, 4000
         sz.Add(b1, 0, 0)
         sz.Add(self.gr, 1, wx.EXPAND)

         self.gr.CreateGrid(self.rows, self.cols)
         self.SetSizerAndFit(sz)
         wx.FutureCall(500, self.create)

     def create(self):
        import time
        t = time.time()
        for row in range(self.rows):
         for col in range(self.cols):
          self.gr.SetCellValue(row, col, str(row+col))
        print time.time() - t

if __name__ == '__main__':
     app = wx.App(0)
     frame = Frame1(None)
     frame.Show(True)
     app.MainLoop()

On my pc it take 0.7/0.8 sec, on 800MHz it take 3.5/4.0 sec.

Like I already said, I try with PyGridTableBase, but I need to use
functions like AppendCols and DeleteCols that apparently cannot be used
with that class (I don't know why).
In your project, do you use they (AppendCols, AppendRows, ...)?

Thanks, -Kartic

Thanks to you,
Michele

For how to notify the grid of row/col changes, see section 1.2 of this page:

http://wiki.wxpython.org/index.cgi/wxGrid

Cheers,

Rad

ยทยทยท

----- Original Message ----- From: "Michele Petrazzo" <michele.petrazzo@unipex.it>
To: <wxPython-users@lists.wxwidgets.org>
Sent: Thursday, October 13, 2005 9:29 AM
Subject: Re: [wxPython-users] Grid update problem

Vladimir Ignatov wrote:

Hi,

In a case of dealing with big/huge tables the only solution is to use
"virtual grid". That is because it "invert" the logic of
application. You don't need to "push" your data to the grid anymore,
intead grid widget will "pull" data from application to the screen.
This is much more optimal approach since only few rows are visible at
any given time.

Ok, very good trick :slight_smile:

The only problem is that "virtual grid" API is a bit um... obscure.

I saw

Learn the demo carefully. The key moment is that you need to send "messages" to the wxGrid widget notifying it about data changes (rows
added/deleted, cell values changed).

Into the demo I see only a grid "friezed", not with add / delete cols
and rows.
However you say that I have to notify the changes, but how can do it?

Vladimir Ignatov

Thanks,
Michele

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org