]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/simple.py
wxGLCanvas updates
[wxWidgets.git] / wxPython / demo / simple.py
CommitLineData
b6e5c445
RD
1
2#----------------------------------------------------------------------
3# A very simple wxPython example. Just a wxFrame, wxPanel,
4# wxStaticText, wxButton, and a wxBoxSizer, but it shows the basic
5# structure of any wxPython application.
6#----------------------------------------------------------------------
7
8from wxPython.wx import *
9
10class MyFrame(wxFrame):
11 def __init__(self, parent, title):
12 wxFrame.__init__(self, parent, -1, title, size=(350, 200))
13
14 menuBar = wxMenuBar()
15 menu = wxMenu()
16 menu.Append(101, "E&xit\tAlt-X", "Exit demo")
17 EVT_MENU(self, 101, self.OnButton)
18 menuBar.Append(menu, "&File")
19 self.SetMenuBar(menuBar)
20
21 panel = wxPanel(self, -1)
22 text = wxStaticText(panel, -1, "Hello World!\nWhere is my menu?")
23 text.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
24 text.SetSize(text.GetBestSize())
25 btn = wxButton(panel, -1, "Close")
26 btn.SetDefault()
27
28 sizer = wxBoxSizer(wxVERTICAL)
29 sizer.Add(text, 0, wxALL, 10)
30 sizer.Add(btn, 0, wxALL, 10)
31 panel.SetSizer(sizer)
32 panel.SetAutoLayout(true)
33 panel.Layout()
34
35 EVT_BUTTON(self, btn.GetId(), self.OnButton)
36
37
38 def OnButton(self, evt):
39 self.Close()
40
41app = wxPySimpleApp()
42frame = MyFrame(None, "Simple wxPython App")
43frame.Show(true)
44app.MainLoop()
45