]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/simple.py
make wxArtProvider pure virtual (I was not so on
[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):
b5a5d647 11 """
a541c325 12 This is MyFrame. It just shows a few controls on a wxPanel,
b5a5d647
RD
13 and has a simple menu.
14 """
b6e5c445
RD
15 def __init__(self, parent, title):
16 wxFrame.__init__(self, parent, -1, title, size=(350, 200))
17
18 menuBar = wxMenuBar()
19 menu = wxMenu()
20 menu.Append(101, "E&xit\tAlt-X", "Exit demo")
21 EVT_MENU(self, 101, self.OnButton)
22 menuBar.Append(menu, "&File")
23 self.SetMenuBar(menuBar)
24
25 panel = wxPanel(self, -1)
a3015b16 26 if wxPlatform == "__WXMAC__":
a541c325 27 text = wxStaticText(panel, -1,
b5a5d647 28 "Hello World!\nWhere is my menu?")
a3015b16
RD
29 else:
30 text = wxStaticText(panel, -1, "Hello World!")
b6e5c445
RD
31 text.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
32 text.SetSize(text.GetBestSize())
33 btn = wxButton(panel, -1, "Close")
34 btn.SetDefault()
35
36 sizer = wxBoxSizer(wxVERTICAL)
37 sizer.Add(text, 0, wxALL, 10)
38 sizer.Add(btn, 0, wxALL, 10)
39 panel.SetSizer(sizer)
40 panel.SetAutoLayout(true)
41 panel.Layout()
42
43 EVT_BUTTON(self, btn.GetId(), self.OnButton)
44
45
46 def OnButton(self, evt):
b5a5d647 47 """Event handler for the button click."""
4268f798 48 print "OnButton"
b6e5c445
RD
49 self.Close()
50
51app = wxPySimpleApp()
52frame = MyFrame(None, "Simple wxPython App")
53frame.Show(true)
54app.MainLoop()
55