]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-05/generictable.py
Added the sample code from wxPython In Action to the samples dir
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-05 / generictable.py
1 import wx
2 import wx.grid
3
4 class GenericTable(wx.grid.PyGridTableBase):
5
6 def __init__(self, data, rowLabels=None, colLabels=None):
7 wx.grid.PyGridTableBase.__init__(self)
8 self.data = data
9 self.rowLabels = rowLabels
10 self.colLabels = colLabels
11
12 def GetNumberRows(self):
13 return len(self.data)
14
15 def GetNumberCols(self):
16 return len(self.data[0])
17
18 def GetColLabelValue(self, col):
19 if self.colLabels:
20 return self.colLabels[col]
21
22 def GetRowLabelValue(self, row):
23 if self.rowLabels:
24 return self.rowLabels[row]
25
26 def IsEmptyCell(self, row, col):
27 return False
28
29 def GetValue(self, row, col):
30 return self.data[row][col]
31
32 def SetValue(self, row, col, value):
33 pass
34