]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/GridHugeTable.py
Warning fixes and source cleaning.
[wxWidgets.git] / wxPython / demo / GridHugeTable.py
CommitLineData
8fa876ca
RD
1
2import wx
3import wx.grid as gridlib
f6bcfd97
BP
4
5#---------------------------------------------------------------------------
6
8fa876ca 7class HugeTable(gridlib.PyGridTableBase):
f6bcfd97 8
f6bcfd97 9 def __init__(self, log):
8fa876ca 10 gridlib.PyGridTableBase.__init__(self)
f6bcfd97
BP
11 self.log = log
12
372bde9b 13 self.odd=gridlib.GridCellAttr()
5499dd89 14 self.odd.SetBackgroundColour("sky blue")
372bde9b 15 self.even=gridlib.GridCellAttr()
5499dd89
RD
16 self.even.SetBackgroundColour("sea green")
17
fbd5dd1d 18 def GetAttr(self, row, col, kind):
5499dd89
RD
19 attr = [self.even, self.odd][row % 2]
20 attr.IncRef()
21 return attr
22
aec587c2
RD
23
24
25 # This is all it takes to make a custom data table to plug into a
26 # wxGrid. There are many more methods that can be overridden, but
27 # the ones shown below are the required ones. This table simply
28 # provides strings containing the row and column values.
29
f6bcfd97
BP
30 def GetNumberRows(self):
31 return 10000
32
33 def GetNumberCols(self):
34 return 10000
35
36 def IsEmptyCell(self, row, col):
1e4a197e 37 return False
f6bcfd97
BP
38
39 def GetValue(self, row, col):
40 return str( (row, col) )
41
42 def SetValue(self, row, col, value):
43 self.log.write('SetValue(%d, %d, "%s") ignored.\n' % (row, col, value))
44
45
46#---------------------------------------------------------------------------
47
48
49
8fa876ca 50class HugeTableGrid(gridlib.Grid):
f6bcfd97 51 def __init__(self, parent, log):
8fa876ca 52 gridlib.Grid.__init__(self, parent, -1)
f6bcfd97
BP
53
54 table = HugeTable(log)
55
56 # The second parameter means that the grid is to take ownership of the
57 # table and will destroy it when done. Otherwise you would need to keep
58 # a reference to it and call it's Destroy method later.
1e4a197e
RD
59 self.SetTable(table, True)
60
8fa876ca 61 self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightDown)
1e4a197e 62
8fa876ca 63 def OnRightDown(self, event):
1e4a197e 64 print "hello"
8fa876ca 65 print self.GetSelectedRows()
f6bcfd97
BP
66
67
68#---------------------------------------------------------------------------
69
8fa876ca 70class TestFrame(wx.Frame):
f6bcfd97 71 def __init__(self, parent, log):
8fa876ca 72 wx.Frame.__init__(self, parent, -1, "Huge (virtual) Table Demo", size=(640,480))
f6bcfd97
BP
73 grid = HugeTableGrid(self, log)
74
1e4a197e 75 grid.SetReadOnly(5,5, True)
f6bcfd97
BP
76
77#---------------------------------------------------------------------------
78
79if __name__ == '__main__':
80 import sys
8fa876ca 81 app = wx.PySimpleApp()
f6bcfd97 82 frame = TestFrame(None, sys.stdout)
1e4a197e 83 frame.Show(True)
f6bcfd97
BP
84 app.MainLoop()
85
86
87#---------------------------------------------------------------------------