]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/GridHugeTable.py
1 from wxPython
.wx
import *
2 from wxPython
.grid
import *
4 #---------------------------------------------------------------------------
6 class HugeTable(wxPyGridTableBase
):
9 This is all it takes to make a custom data table to plug into a
10 wxGrid. There are many more methods that can be overridden, but
11 the ones shown below are the required ones. This table simply
12 provides strings containing the row and column values.
15 def __init__(self
, log
):
16 wxPyGridTableBase
.__init
__(self
)
19 def GetNumberRows(self
):
22 def GetNumberCols(self
):
25 def IsEmptyCell(self
, row
, col
):
28 def GetValue(self
, row
, col
):
29 return str( (row
, col
) )
31 def SetValue(self
, row
, col
, value
):
32 self
.log
.write('SetValue(%d, %d, "%s") ignored.\n' % (row
, col
, value
))
35 #---------------------------------------------------------------------------
39 class HugeTableGrid(wxGrid
):
40 def __init__(self
, parent
, log
):
41 wxGrid
.__init
__(self
, parent
, -1)
43 table
= HugeTable(log
)
45 # The second parameter means that the grid is to take ownership of the
46 # table and will destroy it when done. Otherwise you would need to keep
47 # a reference to it and call it's Destroy method later.
48 self
.SetTable(table
, true
)
52 #---------------------------------------------------------------------------
54 class TestFrame(wxFrame
):
55 def __init__(self
, parent
, log
):
56 wxFrame
.__init
__(self
, parent
, -1, "Huge (virtual) Table Demo", size
=(640,480))
57 grid
= HugeTableGrid(self
, log
)
59 grid
.SetReadOnly(5,5, true
)
61 #---------------------------------------------------------------------------
63 if __name__
== '__main__':
66 frame
= TestFrame(None, sys
.stdout
)
71 #---------------------------------------------------------------------------