]>
Commit | Line | Data |
---|---|---|
be05b434 RD |
1 | import wx |
2 | import wx.grid | |
3 | ||
4 | class LineupTable(wx.grid.PyGridTableBase): | |
5 | ||
6 | data = (("CF", "Bob", "Dernier"), ("2B", "Ryne", "Sandberg"), | |
7 | ("LF", "Gary", "Matthews"), ("1B", "Leon", "Durham"), | |
8 | ("RF", "Keith", "Moreland"), ("3B", "Ron", "Cey"), | |
9 | ("C", "Jody", "Davis"), ("SS", "Larry", "Bowa"), | |
10 | ("P", "Rick", "Sutcliffe")) | |
11 | ||
12 | colLabels = ("Last", "First") | |
13 | ||
14 | def __init__(self): | |
15 | wx.grid.PyGridTableBase.__init__(self) | |
16 | ||
17 | def GetNumberRows(self): | |
18 | return len(self.data) | |
19 | ||
20 | def GetNumberCols(self): | |
21 | return len(self.data[0]) - 1 | |
22 | ||
23 | def GetColLabelValue(self, col): | |
24 | return self.colLabels[col] | |
25 | ||
26 | def GetRowLabelValue(self, row): | |
27 | return self.data[row][0] | |
28 | ||
29 | def IsEmptyCell(self, row, col): | |
30 | return False | |
31 | ||
32 | def GetValue(self, row, col): | |
33 | return self.data[row][col + 1] | |
34 | ||
35 | def SetValue(self, row, col, value): | |
36 | pass | |
37 | ||
38 | class SimpleGrid(wx.grid.Grid): | |
39 | def __init__(self, parent): | |
40 | wx.grid.Grid.__init__(self, parent, -1) | |
41 | self.SetTable(LineupTable()) | |
42 | ||
43 | class TestFrame(wx.Frame): | |
44 | def __init__(self, parent): | |
45 | wx.Frame.__init__(self, parent, -1, "A Grid", | |
46 | size=(275, 275)) | |
47 | grid = SimpleGrid(self) | |
48 | ||
49 | if __name__ == '__main__': | |
50 | app = wx.PySimpleApp() | |
51 | frame = TestFrame(None) | |
52 | frame.Show(True) | |
53 | app.MainLoop() | |
54 |