]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/simple/old_simple.py
Added the ActiveGrid IDE as a sample application
[wxWidgets.git] / wxPython / samples / simple / old_simple.py
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
8 from wxPython.wx import *
9 print "wxVERSION_STRING = ", wxVERSION_STRING
10
11 class MyFrame(wxFrame):
12 """
13 This is MyFrame. It just shows a few controls on a wxPanel,
14 and has a simple menu.
15 """
16 def __init__(self, parent, title):
17 wxFrame.__init__(self, parent, -1, title, size=(350, 200))
18
19 menuBar = wxMenuBar()
20 menu = wxMenu()
21 menu.Append(101, "E&xit\tAlt-X", "Exit demo")
22 EVT_MENU(self, 101, self.OnButton)
23 menuBar.Append(menu, "&File")
24 self.SetMenuBar(menuBar)
25
26 panel = wxPanel(self, -1)
27 text = wxStaticText(panel, -1, "Hello World!")
28 text.SetFont(wxFont(14, wxSWISS, wxNORMAL, wxBOLD))
29 text.SetSize(text.GetBestSize())
30 btn = wxButton(panel, -1, "Close")
31 btn.SetDefault()
32
33 btn2 = wxButton(panel, -1, "Just for fun...")
34
35 sizer = wxBoxSizer(wxVERTICAL)
36 sizer.Add(text, 0, wxALL, 10)
37 sizer.Add(btn, 0, wxALL, 10)
38 sizer.Add(btn2, 0, wxALL, 10)
39 panel.SetSizer(sizer)
40 panel.SetAutoLayout(True)
41 panel.Layout()
42
43 EVT_BUTTON(self, btn.GetId(), self.OnButton)
44 EVT_BUTTON(self, btn2.GetId(), self.OnFunButton)
45
46 def OnButton(self, evt):
47 """Event handler for the button click."""
48 print "OnButton"
49 self.Close()
50
51 def OnFunButton(self, evt):
52 """Event handler for the button click."""
53 print "Having fun yet?"
54
55
56 app = wxPySimpleApp()
57 frame = MyFrame(None, "Simple wxPython App")
58 frame.Show(True)
59 app.MainLoop()
60