0

我有两个框架——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),这只是给出了一个更神秘的错误。

4

1 回答 1

1

您需要在 的实例上调用该方法moreWindow,而不是类moreWindow本身。也就是说,您需要moreWindow在代码中的某处创建一个实例:

more_window = moreWindow()

然后调用show该实例:

more_window.show()

另外,请检查此答案,这正是您想要做的:

https://stackoverflow.com/a/11201346/1157444

于 2012-10-27T15:17:38.017 回答