]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/simple/old_simple.py
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 #----------------------------------------------------------------------
8 from wxPython
.wx
import *
9 print "wxVERSION_STRING = ", wxVERSION_STRING
11 class MyFrame(wxFrame
):
13 This is MyFrame. It just shows a few controls on a wxPanel,
14 and has a simple menu.
16 def __init__(self
, parent
, title
):
17 wxFrame
.__init
__(self
, parent
, -1, title
, size
=(350, 200))
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
)
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")
33 btn2
= wxButton(panel
, -1, "Just for fun...")
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)
40 panel
.SetAutoLayout(True)
43 EVT_BUTTON(self
, btn
.GetId(), self
.OnButton
)
44 EVT_BUTTON(self
, btn2
.GetId(), self
.OnFunButton
)
46 def OnButton(self
, evt
):
47 """Event handler for the button click."""
51 def OnFunButton(self
, evt
):
52 """Event handler for the button click."""
53 print "Having fun yet?"
57 frame
= MyFrame(None, "Simple wxPython App")