2012-06-21 2 views
1

Это мой код. Я хочу, чтобы переопределить метод DrawКак я могу расширить wx.grid.GridCellRenderer?

import wx.grid    as gridlib 

class MyCellRenderer(gridlib.GridCellRenderer): 

    def __init__(self, *args): 
     gridlib.GridCellRenderer.__init__(self, *args) 

    def Draw(self, *args): 
     super(MyCellRenderer,self).Draw(*args) 

... в другой части сценария

 r2 = MyCellRenderer() 
     # self is a grid here 
     self.SetCellRenderer(15,0, r2) 

Это StackTrace

Traceback (most recent call last): 
    File "c:\SY_FI\wxPython-2.8.12.1\demo\GridSimple2.py", line 274, in <module> 
    frame = TestFrame(None, sys.stdout) 
    File "c:\SY_FI\wxPython-2.8.12.1\demo\GridSimple2.py", line 264, in __init__ 
    self.grid = SimpleGrid(self, log) 
    File "c:\SY_FI\wxPython-2.8.12.1\demo\GridSimple2.py", line 96, in __init__ 
    r2 = MyCellRenderer() 
    File "c:\SY_FI\wxPython-2.8.12.1\demo\GridSimple2.py", line 13, in __init__ 
    gridlib.GridCellRenderer.__init__(self) 
    File "D:\ATHENA~1\RELEAS~1\build\ext\vc90_xp/lib\python2.6\site-packages\wx-2.8.12.0\wx\grid.py", line 113, in __init__ 

AttributeError: No constructor defined 

Версия Wx является 2.8.12.0. python - 2.6.6. платформа winxp

ответ

1

Я должен расширить MyCellRenderer от PyGridCellRenderer

Смежные вопросы