Reputation: 8090
I'm trying to update a wx.grid.PyGridTableBase by calling grid.ForceRefresh() after the table data had been changed. However, the number of rows does not get refreshed and so the table is still showing the original (before update) number of rows. Is there anything I can do to completely update the grid?
Upvotes: 2
Views: 2917
Reputation: 33111
You probably forgot to notify the grid of the changes you made. You can find an example in the wxPython demo or you can just read this old thread on the topic:
https://groups.google.com/forum/?fromgroups=#!msg/wxpython-users/z4iobAKq0os/zzUL70WzL_AJ
Which says:
msg = wx.grid.GridTableMessage(self, # The table
wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to it
1 # how many
)
or
msg = wx.grid.GridTableMessage(self, # The table
wx.grid.GRIDTABLE_NOTIFY_ROWS_INSERTED, # what we did to it
5, # from which row
1 # how many
)
or
msg = wx.grid.GridTableMessage(self, # The table
wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, # what we did to it
5, # from which row
1 # how many
)
followed by
self.GetView().ProcessTableMessage(msg)
You can also read about this on the wxPython wiki: http://wiki.wxpython.org/wxGrid
Upvotes: 2