2012-06-21 58 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) 

此的另一部分是堆棧跟蹤

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

我應該從PyGridCellRenderer擴展MyCellRenderer