wxpython使窗口重新显示_在wxPython中显示另一个窗口/帧

我对编程、python和wxpython还比较陌生。我花了几个小时仔细阅读了这段代码,并在网上到处寻找答案。单击菜单项后,无法显示新窗口。这是我的密码。。。import wx

class MainWindow(wx.Frame):

def __init__(self,parent,id):

wx.Frame.__init__(self,parent,id,'Python Test App',size=(600,400))

panel=wx.Panel(self)

wx.Frame.CenterOnScreen(self)

##wx.Frame.Maximize(self)

status=self.CreateStatusBar()

menubar=wx.MenuBar()

file_menu=wx.Menu()

edit_menu=wx.Menu()

ID_FILE_NEW = 1

ID_FILE_OPEN = 2

ID_EDIT_UNDO = 3

ID_EDIT_REDO = 4

file_menu.append(ID_FILE_NEW,"New Window","This is a new window")

file_menu.Append(ID_FILE_OPEN,"Open...","This will open a new window")

edit_menu.Append(ID_EDIT_UNDO,"Undo","This will undo your last action")

edit_menu.Append(ID_EDIT_REDO,"Redo","This will redo your last undo")

menubar.Append(file_menu,"File")

menubar.Append(edit_menu,"Edit")

self.SetMenuBar(menubar)

self.Bind(wx.EVT_MENU, NewWindow.new_frame, None, 1)

class NewWindow(wx.Frame):

def __init__(self,MainWindow,id):

wx.Frame.__init__(self, None, id, 'New Window', size=(600,400))

wx.Frame.CenterOnScreen(self)

self.Show(False)

def new_frame(self, event):

NewWindow.Show(True)

if __name__=='__main__':

app=wx.PySimpleApp()

frame=MainWindow(parent=None,id=-1)

frame.Show()

app.MainLoop()

当我尝试运行此代码时,当我单击菜单项“New Window”(新建窗口)时,会收到此错误消息TypeError: unbound method new_frame() must be called with NewWindow instance as first argument (got CommandEvent instance instead)

再说一遍,我对编程还很陌生。任何帮助都是非常感谢的,而且,我知道我的代码可能不是“最干净”的代码。提前谢谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值