[wx-dev] [ wxwindows-Bugs-1634299 ] PyGridTableBase bug?
SourceForge.net
noreply at sourceforge.net
Fri Apr 25 16:48:26 PDT 2008
Bugs item #1634299, was opened at 2007-01-12 13:34
Message generated for change (Comment added) made by iorange
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1634299&group_id=9863
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxPython specific
Group: None
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: AKap (aleksey_kap)
Assigned to: Robin Dunn (robind)
Summary: PyGridTableBase bug?
Initial Comment:
A bug or not a bug?
Python2.5 windowsXP
with wxPython 2.6.3 all works ok.
with wxPython 2.8.0.1 generated error.
I had this code in my program:
class PhonesDataTable(wx.grid.PyGridTableBase):
.....
.....
def SetValue(self, row, col, value):
try:
self.data[row][col] = value
except IndexError:
# add a new row
self.data.append(['']*self.GetNumberCols())
self.SetValue(row, col, value)
with wxPython 2.6.3 all works ok.
with wxPython 2.8 last row gives error:
'NoneType is not callable'
after changing last row to:
self.data[row][col]=value
all works ok.
----------------------------------------------------------------------
Comment By: israel orange (iorange)
Date: 2008-04-25 18:48
Message:
Logged In: YES
user_id=1529861
Originator: NO
By creating an inner function innerSetValue(row, col, value) and calling
it instead, one can work around this issue. I can't figure out how to
attach a patch for GridCustTable.py to this bug, but here's a working
SetValue function for that file. I hope the code isn't messed up by the
sourceforge software:
def SetValue(self, row, col, value):
def innerSetValue(row, col, value):
try:
self.data[row][col] = value
except IndexError:
# add a new row
self.data.append([''] * self.GetNumberCols())
self.SetValue(row, col, value)
# tell the grid we've added a row
msg = gridlib.GridTableMessage(self, # The table
gridlib.GRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did
to it
1 # how many
)
self.GetView().ProcessTableMessage(msg)
innerSetValue(row, col, value)
----------------------------------------------------------------------
Comment By: israel orange (iorange)
Date: 2008-04-25 18:27
Message:
Logged In: YES
user_id=1529861
Originator: NO
The sample in GridCustTable.py uses this technique, and predictably errors
on a recent wxPython installation. Call it a documentation bug, I guess?
----------------------------------------------------------------------
Comment By: Robin Dunn (robind)
Date: 2007-01-18 11:40
Message:
Logged In: YES
user_id=53955
Originator: NO
For the moment I'm going to call it "not a bug" This happens because of
an implementation detail that allows the base class version of the virtual
method to be called from within the derived version of the method. Since
it is a C++ virtual that is dynamically reflected to the Python method I
had to do some trickery to prevent the call to the base version to be
reflected back to the derived version again, but this also prevents
legitimate recursive calls like you tried.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1634299&group_id=9863
More information about the wx-dev
mailing list