2012-06-21 1 views
1

이것은 내 코드입니다. 내가 스크립트어떻게 wx.grid.GridCellRenderer를 확장 할 수 있습니까?

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

이 다른 부분에 ... 그리기 방법

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) 

를 오버라이드 (override) 할 것은 WX의 버전은 2.8.12.0입니다 스택 트레이스

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 

입니다. 파이썬은 2.6.6입니다. 플랫폼은 winxp입니다.

답변

1

PyGridCellRenderer에서 MyCellRenderer를 확장해야합니다.