1

这是我的代码。我想覆盖 Draw 方法

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。蟒蛇是2.6.6。平台是winxp

4

1 回答 1

1

我应该从 PyGridCellRenderer 扩展 MyCellRenderer

于 2012-06-22T03:23:27.470 回答