]>
Commit | Line | Data |
---|---|---|
be05b434 RD |
1 | import wx |
2 | ||
3 | class MyApp(wx.App): | |
4 | ||
5 | def OnInit(self): | |
6 | frame = MyFrame("Hello World", (50, 60), (450, 340)) | |
7 | frame.Show() | |
8 | self.SetTopWindow(frame) | |
9 | return True | |
10 | ||
11 | class MyFrame(wx.Frame): | |
12 | ||
13 | def __init__(self, title, pos, size): | |
14 | wx.Frame.__init__(self, None, -1, title, pos, size) | |
15 | menuFile = wx.Menu() | |
16 | menuFile.Append(1, "&About...") | |
17 | menuFile.AppendSeparator() | |
18 | menuFile.Append(2, "E&xit") | |
19 | menuBar = wx.MenuBar() | |
20 | menuBar.Append(menuFile, "&File") | |
21 | self.SetMenuBar(menuBar) | |
22 | self.CreateStatusBar() | |
23 | self.SetStatusText("Welcome to wxPython!") | |
24 | self.Bind(wx.EVT_MENU, self.OnAbout, id=1) | |
25 | self.Bind(wx.EVT_MENU, self.OnQuit, id=2) | |
26 | ||
27 | def OnQuit(self, event): | |
28 | self.Close() | |
29 | ||
30 | def OnAbout(self, event): | |
31 | wx.MessageBox("This is a wxPython Hello world sample", | |
32 | "About Hello World", wx.OK | wx.ICON_INFORMATION, self) | |
33 | ||
34 | if __name__ == '__main__': | |
35 | app = MyApp(False) | |
36 | app.MainLoop() |