import wx class Example(wx.Frame): def __init__(self, *args, **kwargs): super(Example, self).__init__(*args, **kwargs) self.InitUI() def InitUI(self): menubar = wx.MenuBar() #menubar functionality fileMenu = wx.Menu() #menubar object fitem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application') #menu object menubar.Append(fileMenu, '&File') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.OnQuit, fitem) #bind the wx.EVT_MENU self.SetSize((300, 200)) self.SetTitle('Simple menu') self.Centre() self.Show(True) def OnQuit(self, e): self.Close() def main(): ex = wx.App() Example(None) ex.MainLoop() if __name__ == '__main__': main()
article
Friday, May 27, 2016
wxPython simple menu example
wxPython simple menu example