Hello fellow wxPython users,
I have noticed one cannot set a custom renderer option in a
wx.gird.GridCellAttr object and use the grid movers. To regenerate
this error use the GridDragable.py example included in the wxDemos
package.
1. Add the following custom renderer to GridDragable.py:
class TestRenderer(gridlib.PyGridCellRenderer):
def __init__(self):
gridlib.PyGridCellRenderer.__init__(self)
2. Add the following method to the DragableGrid class in GridDragable.py:
def updateColAttrs(self):
renderer = TestRenderer()
for col in range(self.GetNumberCols()):
attr = gridlib.GridCellAttr()
attr.SetRenderer(renderer)
self.SetColAttr(col, attr)
3. Finally add a call to updateColAttrs in the DragableGrid class
constructor in GridDragable.py
You will notice the application loads fine and uses the custom
renderer, but if you move a column you will be greeted by a segfault.
The python stack trace is not very useful. I've tried many other
variations of this same code, but I can't get by this error, I'm
fairly certain there is some kind of bug in wxPython or the wx
libraries but I don't know enough about the internals to be too
helpful. Here is the stack trace I see:
Traceback (most recent call last):
File "GridDragable.py", line 197, in updateColAttrs
attr.SetRenderer(renderer)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\grid.py",
line 564, in SetRenderer
return _grid.GridCellAttr_SetRenderer(*args, **kwargs)
TypeError: in method 'GridCellAttr_SetRenderer', expected argument 2
of type 'wxGridCellRenderer *'
As you can see I'm running the most recent release of Python 2.5 and
wx 2.8. If anyone has any ideas for how I could still use a custom
renderer and allow column re-ordering or if I'm missing something
obvious please let me know.
Thanks,
Greg B.