我正在尝试在更改表数据后通过调用 grid.ForceRefresh() 来更新 wx.grid.PyGridTableBase。但是,不会刷新行数,因此该表仍显示原始(更新前)行数。我能做些什么来完全更新网格吗?
问问题
2529 次
1 回答
2
您可能忘记通知网格您所做的更改。您可以在 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
于 2013-01-08T14:21:45.807 回答