当我试图编译时,我得到了错误
C:\Temp\pythonWork\superGui>superGui.py
Traceback (most recent call last):
File "C:\Temp\pythonWork\superGui\superGui.py", line 747, in <module>
MyFrame.disableAll()
TypeError: unbound method disableAll() must be called with MyFrame instance as first argument (got nothing instead)
代码snipet
class MyFrame(wx.Frame):
---- CODE SNIP ----
def disableAll(self):
self.btnBeginInstall.Disable()
self.btnBeginInstall.Disable()
self.btnInfraSystem.Disable()
self.btnIwpcSystem.Disable()
self.btnIwpcSystem.Disable()
self.btnIwpcIwpcdba.Disable()
self.btnLdapOc4jadmin.Disable()
self.btnLdapOrcladmin.Disable()
self.btnIas_admin.Disable()
self.btniwpcadmin.Disable()
self.btnAll.Disable()
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
mainFrame = MyFrame(None, -1, "")
app.SetTopWindow(mainFrame)
mainFrame.Show()
#disable the buttons
success = MyFrame.disableAll()
app.MainLoop()
我看了其他几个类似的问题,但答案并没有跳出我,或者更可能是我只是不明白。
你把它当作一个类或静态方法来调用。
self
应该来自哪里?您必须对应该执行某些操作的对象调用方法,即mainFrame.disableAll()
。另外,
success
将是None
,因为disableAll
不返回任何内容。你想干什么?而不是
这样就可以了。
您可能需要使用该类的实例。
如其他答案所示,应该做到这一点。
相关问题 更多 >
编程相关推荐