Python:未绑定的方法

时间:2014-06-30 02:39:43

标签: python python-2.7 wxpython

这里的前言是我收到的错误:

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))

1 个答案:

答案 0 :(得分:0)

添加这些行。

import wx

app = wx.App(False)
Test(None, "hello")
app.MainLoop()