I'm trying to display a PyGridTableBase in a wx.Dialog, but all that
is showing up is one cell in the upper left corner. I have tried this
with and without panels and sizers, but it always has the same
display. Any help would be appreciated.
bob k.
#!/usr/bin/python
# dialogChemicalTable.py
import wx
import wx.grid
def create(parent):
return DialogChemicalTable(parent)
class ChemicalGridTable(wx.grid.PyGridTableBase):
def __init__(self):
wx.grid.PyGridTableBase.__init__(self)
self.data ={
(1,1) : "here",
(2,2) : "is",
(3,3) : "some",
(4,4) : "data",
}
# required methods
def GetNumberRows(self):
return 50
def GetNumberCols(self):
return 50
def GetValue(self, row, col):
value = self.data.get((row,col))
if value is not None:
return value
else:
return ''
def IsEmptyCell(self, row, col):
return self.data.get((row, col)) is not None
def SetValue(self, row, col, value):
self.data[(row,col)]=value
# additional properties
def GetAttr(self, row, col, kind):
attr = [self.even, self.odd][row %2]
attr.IncRef()
return attr
class DialogChemicalTable(wx.Dialog):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Dialog.__init__(self, id=wx.ID_ANY,
name='DialogChemicalTable', parent=prnt, pos=wx.Point(780,
336),
size=wx.Size(598, 411),
style=wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE,
title='Edit Chemical Table')
self.SetClientSize(wx.Size(582, 373))
# panels
panelMain = wx.Panel(self, wx.ID_ANY)
panelMain.SetBackgroundColour('blue')
grid = wx.grid.Grid(self)
table = ChemicalGridTable()
grid.SetTable(table, True)
self.Center()
self.Show(True)
def __init__(self, parent):
self._init_ctrls(parent)