我有两个帧 - MainWindow,这是"主要"框架,而Morewindow是Mainwindow的孩子。当单击Mainwindow中的按钮时,我想显示MoreWindow。这是我正在尝试的:
def showChild(nil):
moreWindow.Show()
class mainWindow(wx.Frame):
def __init__:
buttonMore.Bind(wx.EVT_BUTTON, showChild)
class moreWindow(wx.Frame):
TypeError: unbound method Show() must be called with moreWindow instance as first argument (got nothing instead)
我尝试使用moreWindow.Show(moreWindow)
,这只是给出了一个更神秘的错误。
您需要在moreWindow
的实例上调用该方法,而不是类moreWindow
本身。也就是说,您需要在代码中某个地方创建一个moreWindow
的实例:
more_window = moreWindow()
然后在该实例上致电show
:
more_window.show()
另外,检查这个答案,这正是您要做的:
https://stackoverflow.com/a/11201346/1157444