【发布时间】:2014-06-30 02:39:43
【问题描述】:
这里是我收到的错误的序言:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "TestR.py", line 13, in __init__
wx.Frame.__init__(self, parent = None, title = "Input Data", size = (1250,
750))
TypeError: unbound method __init__() must be called with Frame instance as
first argument (got nothing instead)
当我输入这个时:
j = Test(None, "hello")
使用此代码:
import wx
class Test(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent = None, title = "Input Data", size = (1250, 750))
【问题讨论】:
-
这不是你使用
super的方式。第一个参数是您正在编写的类的名称,而不是超类。此外,如果您的基类未设计为在多重继承中协同工作,则不能将__super__用于__init__调用。 (如果它们被设计为这样一起工作,您只需拨打一个__super__电话。) -
已编辑 - 仍然是个问题。
-
你能显示完整的回溯吗?
-
你为什么要继承
Data和Frame类呢?您可以在这里使用“适配器模式”或“依赖注入” -
就是整个回溯
标签: python python-2.7 wxpython