windows - 学习wxpython时遇到的问题
天蓬老师
天蓬老师 2017-04-17 17:01:58
0
1
285
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all (1)
迷茫

格式看着蛋疼,报错信息已经给你指出这句有问题wx.EVT_MENU(self, 105, self.OnQuit),你是照着这个链接描述来的,看这样子没问题,估计是你的格式错误

#/usr/python #coding=utf-8 import wx class MyMenu(wx.Frame): def __init__(self, parent, ID, title): wx.Frame.__init__(self, parent, -1, title, wx.DefaultPosition, wx.Size(380, 250)) menubar = wx.MenuBar() file = wx.Menu() edit = wx.Menu() help = wx.Menu() file.Append(101, '&Open', 'Open a new document') file.Append(102, '&Save', 'Save the document') file.AppendSeparator() quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the Application') quit.SetBitmap(wx.Image ('gtk-quit.png',wx.BITMAP_TYPE_PNG).ConvertToBitmap()) file.AppendItem(quit) edit.Append(201, 'check item1', '', wx.ITEM_CHECK) edit.Append(202, 'check item2', kind= wx.ITEM_CHECK) submenu = wx.Menu() submenu.Append(301, 'radio item1', kind=wx.ITEM_RADIO) submenu.Append(302, 'radio item2', kind=wx.ITEM_RADIO) submenu.Append(303, 'radio item3', kind= wx.ITEM_RADIO) edit.AppendMenu(203, 'submenu', submenu) menubar.Append(file, '&File') menubar.Append(edit, '&Edit') menubar.Append(help, '&Help') self.SetMenuBar(menubar) self.Centre() wx.EVT_MENU(self, 105, self.OnQuit) def OnQuit(self, event): self.Close() class MyApp(wx.App): def OnInit(self): frame = MyMenu(None, -1, 'menu2.py') frame.Show(True) return True app = MyApp(0) app.MainLoop()
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!