def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(300, 200)) menu = wxMenu() menu.Append(ID_DIALOG, "D&ialog", "Show dialog") menu.Append(ID_EXIT, "E&xit", "Terminate the program") menuBar = wxMenuBar() menuBar.Append(menu, "&File") self.SetMenuBar(menuBar) EVT_MENU(self, ID_EXIT, self.DoExit) EVT_MENU(self, ID_DIALOG, self.DoDialog)
def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(300, 200)) menu = wxMenu() menu.Append(ID_EXIT, "E&xit", "Terminate the program") menuBar = wxMenuBar() menuBar.Append(menu, "&File") self.SetMenuBar(menuBar) EVT_MENU(self, ID_EXIT, self.DoExit) # make sure reactor.stop() is used to stop event loop: EVT_CLOSE(self, lambda evt: reactor.stop())
import wx mw = wx.GetTopLevelWindows()[0] mw.SetStatusText("hello!") menu = mw.GetMenuBar() mymenu = wx.wxMenu() mymenu.Append(wx.wxID_ABOUT,"My &Menu","A sample menu item") menu.Append(mymenu,"Test") dia = wx.Dialog(None,-1) pan = wx.Panel(dia,-1) box = wx.BoxSizer(wx.VERTICAL) box.Add(wx.StaticText(pan,-1,"Hello World!")) box.Add(wx.Button(pan,-1,"Press me!")) pan.SetSizer(box) dia.Show()