wxpython 菜单由MenuBar(菜单栏)->Menu(菜单)->MenuItem(子菜单)构成 #!/usr/bin/python import wx class SimpleMenu(wx.Frame): def __init__(self,parent,id,title): wx.Frame.__init__(self,parent,id,title) menubar = wx.MenuBar() #Creat a menubar File = wx.Menu() #Creat a menu #wx.MenuItem(wx.window parent ,int id, String name,String help) Quit = wx.MenuItem(File,1,"&Quit /tCttl+Q")#Creat a MenuItem Quit.SetBitmap(wx.Bitmap(r'D:/Icon/Icon/001.png'))#set the "Quit" of menuitem's icon File.AppendItem(Quit) #Add the Quit menuitem self.Bind(wx.EVT_MENU,self.OnClose,id=1) #bind the quit event menubar.Append(File,"&File"); self.SetMenuBar(menubar) self.Center() self.Show(True); def OnClose(self,event): self.Close(True); app=wx.PySimpleApp() SimpleMenu(None,-1,"SimpleMenu") app.MainLoop()