]>
Commit | Line | Data |
---|---|---|
be05b434 RD |
1 | import wx |
2 | import wx.grid | |
3 | ||
4 | class TestTable(wx.grid.PyGridTableBase): | |
5 | def __init__(self): | |
6 | wx.grid.PyGridTableBase.__init__(self) | |
7 | self.rowLabels = ["uno", "dos", "tres", "quatro", "cinco"] | |
8 | self.colLabels = ["homer", "marge", "bart", "lisa", "maggie"] | |
9 | ||
10 | def GetNumberRows(self): | |
11 | return 5 | |
12 | ||
13 | def GetNumberCols(self): | |
14 | return 5 | |
15 | ||
16 | def IsEmptyCell(self, row, col): | |
17 | return False | |
18 | ||
19 | def GetValue(self, row, col): | |
20 | return "(%s,%s)" % (self.rowLabels[row], self.colLabels[col]) | |
21 | ||
22 | def SetValue(self, row, col, value): | |
23 | pass | |
24 | ||
25 | def GetColLabelValue(self, col): | |
26 | return self.colLabels[col] | |
27 | ||
28 | def GetRowLabelValue(self, row): | |
29 | return self.rowLabels[row] | |
30 | ||
31 | class TestFrame(wx.Frame): | |
32 | def __init__(self): | |
33 | wx.Frame.__init__(self, None, title="Grid Table", | |
34 | size=(500,200)) | |
35 | grid = wx.grid.Grid(self) | |
36 | table = TestTable() | |
37 | grid.SetTable(table, True) | |
38 | ||
39 | app = wx.PySimpleApp() | |
40 | frame = TestFrame() | |
41 | frame.Show() | |
42 | app.MainLoop() |