re-table a wxGrid

If just the contents of the grid table changed, you have to call GridTableMessage(). Here is one example

    import wx.grid as grid
    ...
    class myGrid(grid.Grid):
        def __init__(self, parent, table, ...):
            self._table = table
            self.SetTable(self._table, ...)
            ...

        def ForceRefresh(self):
            m = Grid.GridTableMessage(self._table, Grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
            self.ProcessTableMessage(m)
            grid.Grid.ForceRefresh(self)

Additional GridTableMessage() calls are required after the number or rows amd/or columns changed. More at

  <http://mail.python.org/pipermail/python-list/2004-November/251679.html&gt;

/Jean Bouwers

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

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