我正在尝试通过在更改表数据后调用grid.ForceRefresh()来更新wx.grid.PyGridTableBase。但是,行数不会刷新,因此表仍显示原始(更新前)行数。有什么办法可以完全更新网格吗?
答案 0 :(得分:1)
您可能忘记通知网格您所做的更改。您可以在wxPython演示中找到一个示例,或者您可以在主题上阅读这个旧主题:
https://groups.google.com/forum/?fromgroups=#!msg/wxpython-users/z4iobAKq0os/zzUL70WzL_AJ
其中说:
msg = wx.grid.GridTableMessage(self, # The table
wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to it
1 # how many
)
或
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
)
或
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
)
接着是
self.GetView().ProcessTableMessage(msg)
您还可以在wxPython wiki上阅读此内容:http://wiki.wxpython.org/wxGrid