What is the third argument to this function? The doc only shows
row and column being supplied. The third argument always seems
to be zero.
There also appears to be some iffy memory management going on
(ie coredumps wxPython). To repeat using the demo, try this.
Edit GridHugeTable.py and add these four lines at the end of
the __init__ method for HugeTable(wxPyGridTableBase):
self.odd=wxGridCellAttr()
self.odd.SetBackgroundColour("RED")
self.even=wxGridCellAttr()
self.even.SetBackgroundColour("GREEN")
Also add this method:
def GetAttr(self,row,col,other):
print row,col,other
return [self.even,self.odd][row%2]
Run that one from the demo and watch the cores dump. The backtrace
looks like this:
(gdb) bt
#0 0x00000059 in ?? ()
#1 0x404d825e in wxGrid::AutoSizeColOrRow(int, bool, bool) (this=0x8b270f8, colOrRow=0, setAsMin=true, column=true)
at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/generic/grid.cpp:9285
#2 0x404dedaf in wxGrid::AutoSizeColumn(int, bool) (this=0x8b270f8, col=0, setAsMin=true)
at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/include/wx/generic/grid.h:1291
#3 0x404d8771 in wxGrid::SetOrCalcColumnSizes(bool, bool) (this=0x8b270f8, calcOnly=false, setAsMin=true)
at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/generic/grid.cpp:9372
#4 0x4106e542 in _wrap_wxGrid_AutoSizeColumns (self=0x0, args=0x8b27074, kwargs=0x8c03cbc)
at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/include/wx/generic/grid.h:1297
#0 is obviously a null pointer derefence. #1 is this:
(gdb) up
#1 0x404d825e in wxGrid::AutoSizeColOrRow(int, bool, bool) (this=0x8b270f8, colOrRow=0, setAsMin=true, column=true)
at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/generic/grid.cpp:9285
9285 attr->DecRef();
Current language: auto; currently c++
(gdb) l
9280 }
9281
9282 renderer->DecRef();
9283 }
9284
9285 attr->DecRef();
9286 }
9287
9288 // now also compare with the column label extent
9289 wxCoord w, h;
So somehow the attribute ended up being a null pointer, even though the
wx code is doing reference counting. If you change the Python GetAttr
function to call .Clone() on the returned object then there are no
more cores. However the above does make me worry about memory leaks,
plus the grotesque inefficiency of returning a new cloned object for
every visible table cell.
Roger