众所周知,虚拟 wx.gridtablebase 模型能够显示无限行,但它失败了大约 7M 行。以下最小示例在 wx 版本上进行了测试:
4.1.2a1.dev5165+64e5d863 msw (phoenix) wxWidgets 3.1.5。谢谢。
import wx
import wx.grid
class GTable(wx.grid.GridTableBase):
def __init__(self):
wx.grid.GridTableBase.__init__(self)
def GetNumberRows(self):
return 10000000
def GetNumberCols(self):
return 2
def GetColLabelValue(self, col):
return "A"+str(col)
def GetRowLabelValue(self, row):
return str(row+1)
def IsEmptyCell(self, row, col):
return False
def GetValue(self, row, col):
return str(row)+'-'+str(col)
def SetValue(self, row, col, value):
pass
class MyGrid(wx.grid.Grid):
def __init__(self, parent):
wx.grid.Grid.__init__(self, parent, -1)
gtable = GTable()
self.SetTable(gtable,True)
#self.MakeCellVisible(1000000,0)
#self.AdjustScrollbars()
#self.ForceRefresh()
#self.Bind(wx.EVT_SCROLLWIN, self.OnScroll)
class TestFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "A Grid", size=(400, 400))
grid = MyGrid(self)
if __name__ == '__main__':
app = wx.App()
frame=TestFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()