Unfortunately this is yet another grid resize question.
I’ve attached a foo.py that demonstrates my problem.
When the refresh button is pressed, the data (just a simple python list) gets modified (grows or shrinks).
I’m trying to get the grid to re-create itself (or update itself) when this happens.
I’m following the example here: http://wiki.wxpython.org/wxGrid
But for some reason the number of rows just keeps growing.
I suspect the bug lies in this part of the code:
/// myDataList has just been modified (randomly added or removed rows), so now it’s time to update the grid to display this new data:
self.grid.BeginBatch()
current, new, delmsg, addmsg = (len(self.myDataList), self.grid.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED)
if new < current:
print 'deleting rows:', current-new
msg = wx.grid.GridTableMessage(
self.grid.GetTable(),
delmsg,
new, # position
current-new,
)
self.grid.ProcessTableMessage(msg)
elif new > current:
print 'adding rows: ', new-current
msg = wx.grid.GridTableMessage(
self.grid.GetTable(),
addmsg,
new-current
)
self.grid.ProcessTableMessage(msg)
msg = wx.grid.GridTableMessage(self.grid.GetTable(), wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
self.grid.ProcessTableMessage(msg)
self.grid.EndBatch()
Any ideas what could be wrong? It’s driving me nuts!
Thanks!
foo.py (3.38 KB)