]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-05/gridModel.py
4 class LineupTable(wx
.grid
.PyGridTableBase
):
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"))
12 colLabels
= ("Last", "First")
15 wx
.grid
.PyGridTableBase
.__init
__(self
)
17 def GetNumberRows(self
):
20 def GetNumberCols(self
):
21 return len(self
.data
[0]) - 1
23 def GetColLabelValue(self
, col
):
24 return self
.colLabels
[col
]
26 def GetRowLabelValue(self
, row
):
27 return self
.data
[row
][0]
29 def IsEmptyCell(self
, row
, col
):
32 def GetValue(self
, row
, col
):
33 return self
.data
[row
][col
+ 1]
35 def SetValue(self
, row
, col
, value
):
38 class SimpleGrid(wx
.grid
.Grid
):
39 def __init__(self
, parent
):
40 wx
.grid
.Grid
.__init
__(self
, parent
, -1)
41 self
.SetTable(LineupTable())
43 class TestFrame(wx
.Frame
):
44 def __init__(self
, parent
):
45 wx
.Frame
.__init
__(self
, parent
, -1, "A Grid",
47 grid
= SimpleGrid(self
)
49 if __name__
== '__main__':
50 app
= wx
.PySimpleApp()
51 frame
= TestFrame(None)