]>
Commit | Line | Data |
---|---|---|
f6bcfd97 BP |
1 | from wxPython.wx import * |
2 | from wxPython.grid import * | |
3 | ||
4 | #--------------------------------------------------------------------------- | |
5 | ||
6 | class HugeTable(wxPyGridTableBase): | |
7 | ||
8 | """ | |
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. | |
13 | """ | |
14 | ||
15 | def __init__(self, log): | |
16 | wxPyGridTableBase.__init__(self) | |
17 | self.log = log | |
18 | ||
19 | def GetNumberRows(self): | |
20 | return 10000 | |
21 | ||
22 | def GetNumberCols(self): | |
23 | return 10000 | |
24 | ||
25 | def IsEmptyCell(self, row, col): | |
1e4a197e | 26 | return False |
f6bcfd97 BP |
27 | |
28 | def GetValue(self, row, col): | |
29 | return str( (row, col) ) | |
30 | ||
31 | def SetValue(self, row, col, value): | |
32 | self.log.write('SetValue(%d, %d, "%s") ignored.\n' % (row, col, value)) | |
33 | ||
34 | ||
35 | #--------------------------------------------------------------------------- | |
36 | ||
37 | ||
38 | ||
39 | class HugeTableGrid(wxGrid): | |
40 | def __init__(self, parent, log): | |
41 | wxGrid.__init__(self, parent, -1) | |
42 | ||
43 | table = HugeTable(log) | |
44 | ||
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. | |
1e4a197e RD |
48 | self.SetTable(table, True) |
49 | ||
50 | EVT_GRID_CELL_RIGHT_CLICK(self, self.OnRightDown) #added | |
51 | ||
52 | def OnRightDown(self, event): #added | |
53 | print "hello" | |
54 | print self.GetSelectedRows() #added | |
55 | ||
56 | ||
f6bcfd97 BP |
57 | |
58 | ||
59 | ||
60 | #--------------------------------------------------------------------------- | |
61 | ||
62 | class TestFrame(wxFrame): | |
63 | def __init__(self, parent, log): | |
64 | wxFrame.__init__(self, parent, -1, "Huge (virtual) Table Demo", size=(640,480)) | |
65 | grid = HugeTableGrid(self, log) | |
66 | ||
1e4a197e | 67 | grid.SetReadOnly(5,5, True) |
f6bcfd97 BP |
68 | |
69 | #--------------------------------------------------------------------------- | |
70 | ||
71 | if __name__ == '__main__': | |
72 | import sys | |
73 | app = wxPySimpleApp() | |
74 | frame = TestFrame(None, sys.stdout) | |
1e4a197e | 75 | frame.Show(True) |
f6bcfd97 BP |
76 | app.MainLoop() |
77 | ||
78 | ||
79 | #--------------------------------------------------------------------------- |