如题,尝试在一级菜单中绑定单机事件,但无论如何尝试都以失败告终.
发现在菜单追加的二级菜单是可以正常绑定事件的,但是一级菜单wx.Menu即使是绑定wx.EVTMENUOPEN事件也会导致无法显示,求解决!
编译环境:Eclipse+Pydev+Python2.7
我的代码如下,虽然编译通过了,但是无法正常显示:
#-*- coding: utf-8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.frame = rpFrame(parent=None, id=-1)
self.frame.Show()
self.SetTopWindow(self.frame)
return True
class rFrame(wx.Frame):
def __init__(self, parent=None, id=-1):
wx.Frame.__init__(self, parent, id,'标题')
#状态栏
statusBar = self.CreateStatusBar()
#菜单栏
menuBar = wx.MenuBar()
self.SetMenuBar(menuBar)
#菜单
menu1 = wx.Menu()
menuBar.Append(menu1, "文件")
menu2 = wx.Menu()
menuBar.Append(menu2, "退出")
#绑定事件
self.Bind(wx.EVT_MENU, self.OnCloseMe, menu1)
def OnCloseMe(self, event):
self.Close(True)
if __name__ == '__main__':
app = App()
app.MainLoop()
The modified program still cannot run and there is an error.
There may be a problem with your Bind usage.