]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-14/grid_table.py
4 class TestTable(wx
.grid
.PyGridTableBase
):
6 wx
.grid
.PyGridTableBase
.__init
__(self
)
7 self
.data
= { (1,1) : "Here",
13 self
.odd
=wx
.grid
.GridCellAttr()
14 self
.odd
.SetBackgroundColour("sky blue")
15 self
.odd
.SetFont(wx
.Font(10, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
17 self
.even
=wx
.grid
.GridCellAttr()
18 self
.even
.SetBackgroundColour("sea green")
19 self
.even
.SetFont(wx
.Font(10, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
22 # these five are the required methods
23 def GetNumberRows(self
):
26 def GetNumberCols(self
):
29 def IsEmptyCell(self
, row
, col
):
30 return self
.data
.get((row
, col
)) is not None
32 def GetValue(self
, row
, col
):
33 value
= self
.data
.get((row
, col
))
39 def SetValue(self
, row
, col
, value
):
40 self
.data
[(row
,col
)] = value
43 # the table can also provide the attribute for each cell
44 def GetAttr(self
, row
, col
, kind
):
45 attr
= [self
.even
, self
.odd
][row
% 2]
51 class TestFrame(wx
.Frame
):
53 wx
.Frame
.__init
__(self
, None, title
="Grid Table",
56 grid
= wx
.grid
.Grid(self
)
59 grid
.SetTable(table
, True)
62 app
= wx
.PySimpleApp()