0

The virtual wx.gridtablebase model is known to be able showing infinite rows, but it failed around 7M rows. The following minimal example is tested on wx version:
4.1.2a1.dev5165+64e5d863 msw (phoenix) wxWidgets 3.1.5. Thanks.

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()
LWX
  • 1
  • 1
  • 1
    @LMX, which platform? Can you reproduce it C++ grid sample? What is happening- you receive an assert or it just slows down? – Igor Aug 19 '21 at 11:59
  • @Igor: Thanks for your comment. OS is windows 10. Sorry, I'm a beginner of wxPython, I don't know how to reproduce it in C++. Do you have any recommendation site or books for me to learn about wxpython in C++? I guess the wx.grid failed to release (or free) some kind of resources(memory?) when data viewing windows moves from one position to another... – LWX Aug 19 '21 at 18:16
  • wxPython is a wrapper around `wxWidgets` C++ library, They are 2 independent things. Now what happen in your case? And what do we do in order to see a problem? – Igor Aug 19 '21 at 18:55
  • What exactly do you mean by "failed"? I.e. what exactly happens when you run your example? – VZ. Aug 19 '21 at 23:07
  • The wx.grid will be crashed when it showing 7M rows. – LWX Aug 20 '21 at 05:20

0 Answers0