re-table a wxGrid

Bryan Cole wrote:

Hi,

I want to dynamically change the wxGridTableBase used by a wxGrid control.
Is this possible?

I'm using a wxGrid to display the values in a NxM array. Using a custom
wxPyGridTableBase, the first time I call wxGrid.SetTable(), everything
works OK.

When I want to display a different Array, I instantiate a new
wxPyGridTableBase with new table dimensions. However, when I call
grid.SetTable() with this new table, the displayed grid is not
changed.

What's the correct way to redefine the dimensions and contents of a
wxGrid? Do I have to destroy the wxGrid control and create a new one?

thanks,
Bryan

From the wiki at http://wiki.wxpython.org/index.cgi/wxPyGridTableBase
wxPyGridTableBase - wxPython Wiki

"You associate your wxPyGridTableBase object with your wxGrid object by calling wxGrid::SetTable(myTable) during initialization of the grid. Important note: you cannot call SetTable more than once for a given grid. If you need to change tables, you'll need to create a new wxGrid object. Also, depending on your version of wxPython, you may not be able to use the built-in GetView() method, as it will not return your Python wxGrid instance. You should consider storing a Python weak reference to the grid object in your table object (you will constantly need to access the grid object from your table class, incidentally)."

Paul Probert