60 # Start of file 14 from wxPython.wx import * 15 16 ID_ABOUT = 101
17 ID_EXIT = 102 18 19 class MyFrame(wxFrame): 20 def __init__(self, parent, ID, title): 21 wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(200, 150)) 22 self.CreateStatusBar()
23 self.SetStatusText("This is the statusbar") 24 25 menu = wxMenu() 26 menu.Append(ID_ABOUT, "&About","More information about this program")
27 menu.AppendSeparator() 28 menu.Append(ID_EXIT, "E&xit", "Terminate the program") 29 30 menuBar = wxMenuBar() 31 menuBar.Append(menu, "&File");
32 33 self.SetMenuBar(menuBar) 34 35 EVT_MENU(self, ID_ABOUT, self.OnAbout) 36 EVT_MENU(self, ID_EXIT, self.TimeToQuit) 37 38 def OnAbout(self, event):
39 dlg = wxMessageDialog(self, "This sample program shows off/n" 40 "frames, menus, statusbars, and this/n" 41 "message dialog.", 42 "About Me", wxOK | wxICON_INFORMATION)
43 dlg.ShowModal() 44 dlg.Destroy() 45 46 def TimeToQuit(self, event): 47 self.Close(True) 48 49 class App(wxApp):
50 def OnInit(self): 51 frame = MyFrame(NULL, -1, "Hello from wxPython") 52 frame.Show(True) 53 self.SetTopWindow(frame) 54 return True
55 56 if __name__ == "__main__": 57 app = App(0) 58 app.MainLoop() 59 60 # end of file
|