代码:
1 #!/usr/bin/env python
2
3 import wx
4 class MuneEventFrame(wx.Frame):
5 def __init__(self,parent,id):
6 wx.Frame.__init__(self,parent,id,"test",size=(300,200))
7 menuBar=wx.MenuBar()
8 menu1=wx.Menu()
9 menuItem=menu1.Append(-1,"&Exit...")
10 menuBar.Append(menu1,"&File")
11 self.SetMenuBar(menuBar)
12 self.Bind(wx.EVT_MENU,self.OnCloseMe,menuItem)
13
14 def OnCloseMe(self,event):
15 self.Close(True)
16
17 if __name__=="__main__":
18 app=wx.PySimpleApp()
19 frame=MuneEventFrame(None,-1)
20 frame.Show()
21 app.MainLoop()
结果:
1 #!/usr/bin/env python
2
3 import wx
4 class MuneEventFrame(wx.Frame):
5 def __init__(self,parent,id):
6 wx.Frame.__init__(self,parent,id,"test",size=(300,200))
7 menuBar=wx.MenuBar()
8 menu1=wx.Menu()
9 menuItem=menu1.Append(-1,"&Exit...")
10 menuBar.Append(menu1,"&File")
11 self.SetMenuBar(menuBar)
12 self.Bind(wx.EVT_MENU,self.OnCloseMe,menuItem)
13
14 def OnCloseMe(self,event):
15 self.Close(True)
16
17 if __name__=="__main__":
18 app=wx.PySimpleApp()
19 frame=MuneEventFrame(None,-1)
20 frame.Show()
21 app.MainLoop()
结果: