显示孩子wx.Frame?

时间:2012-10-27 14:51:22

标签: python wxpython

我有两个框架 - mainWindow,它是“主要”框架,而更多窗口是mainWindow的子框架。当点击mainWindow中的按钮时,我想显示更多窗口。这是我正在尝试的:

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),这只是一个更加神秘的错误。

1 个答案:

答案 0 :(得分:1)

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

more_window = moreWindow()

然后在该实例上调用show

more_window.show()

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

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