| 1 |
from wxPython.wx import *
|
| 2 |
|
| 3 |
ID_ABOUT = 101
|
| 4 |
ID_EXIT = 102
|
| 5 |
|
| 6 |
class MyFrame(wxFrame):
|
| 7 |
def __init__(self, parent, ID, title):
|
| 8 |
wxFrame.__init__(self, parent, ID, title,
|
| 9 |
wxDefaultPosition, wxSize(200, 150))
|
| 10 |
self.CreateStatusBar()
|
| 11 |
self.SetStatusText("This is the statusbar")
|
| 12 |
|
| 13 |
menu = wxMenu()
|
| 14 |
menu.Append(ID_ABOUT, "&About",
|
| 15 |
"More information about this program")
|
| 16 |
menu.AppendSeparator()
|
| 17 |
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
|
| 18 |
|
| 19 |
menuBar = wxMenuBar()
|
| 20 |
menuBar.Append(menu, "&File");
|
| 21 |
|
| 22 |
self.SetMenuBar(menuBar)
|
| 23 |
EVT_MENU(self, ID_ABOUT, self.OnAbout)
|
| 24 |
EVT_MENU(self, ID_EXIT, self.TimeToQuit)
|
| 25 |
|
| 26 |
def OnAbout(self, event):
|
| 27 |
dlg = wxMessageDialog(self, "This sample program shows off\n"
|
| 28 |
"frames, menus, statusbars, and this\n"
|
| 29 |
"message dialog.",
|
| 30 |
"About Me", wxOK | wxICON_INFORMATION)
|
| 31 |
dlg.ShowModal()
|
| 32 |
dlg.Destroy()
|
| 33 |
|
| 34 |
|
| 35 |
def TimeToQuit(self, event):
|
| 36 |
self.Close(true)
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
class MyApp(wxApp):
|
| 41 |
def OnInit(self):
|
| 42 |
frame = MyFrame(NULL, -1, "Hello from wxPython")
|
| 43 |
frame.Show(true)
|
| 44 |
self.SetTopWindow(frame)
|
| 45 |
return true
|
| 46 |
|
| 47 |
app = MyApp(0)
|
| 48 |
app.MainLoop()
|