[wxPython-users] Application Breaks Using Python-2.5
Rich Shepard
rshepard at appl-ecosys.com
Mon Nov 12 15:07:30 PST 2007
On Mon, 12 Nov 2007, Robin Dunn wrote:
> The error is telling you that the requested col doesn't exist. Are you sure
> that i is less than the number of columns in the grid?
Robin,
It should be. The last time I edited that page was 2007-09-01, and it's
worked flawlessly with Python-2.4.3 and wxPython-2.8.0.1. I upgraded the
distribution on the notebook so it's running Python-2.5.1 and
wxPython-2.8.6.1.
The code at the top of the module is:
class dataTable(wx.grid.PyGridTableBase):
data = appData.altData
rowLabels = ()
colLabels = ()
def __init__(self, data, rowLabels=None, colLabels=None):
wx.grid.PyGridTableBase.__init__(self)
self.data = data
self.rowLabels = rowLabels
self.colLabels = colLabels
def GetNumberRows(self):
if self.appData.projname != ' ':
self.appData.cur.execute("select count(*) from Variable")
self.nRows = self.appData.fetchall()
return self.nRows
else:
return 24
def GetNumberCols(self):
# return len(self.data[0])
return 33
...
class modData(wx.Panel):
def __init__(self, prnt, ID):
wx.Panel.__init__(self, prnt, wx.ID_ANY)
self.SetHelpText('Enter, edit, and remove existing condition data and alternatives here.')
topLevelBox = wx.BoxSizer(wx.VERTICAL) # Base container for all widgets
outerBox = wx.BoxSizer(wx.VERTICAL) # Adds to space around widgets
buttonBox = wx.BoxSizer(wx.HORIZONTAL) # For the Save button; allows placement across
widgetBox = wx.BoxSizer(wx.VERTICAL) # Holds grid and save button
# Here's where the grid widget is defined.
self.dataGrid = wx.grid.Grid(self, size=wx.Size(770,440))
table = dataTable(self)
self.dataGrid.SetTable(table, True)
# simple cell formatting
for i in range(0,34):
self.dataGrid.SetColSize(i, 125)
self.dataGrid.AutoSizeColumns(setAsMin=True)
GetNumberCols() returns 33, and setColSize() matches that.
Thanks,
Rich
--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
More information about the wxpython-users
mailing list