]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/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 *
10 class MyFrame(wxFrame
):
12 This is MyFrame. It just shows a few controls on a wxPanel,
13 and has a simple menu.
15 def __init__(self
, parent
, title
):
16 wxFrame
.__init
__(self
, parent
, -1, title
, size
=(350, 200))
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
)
25 panel
= wxPanel(self
, -1)
26 if wxPlatform
== "__WXMAC__":
27 text
= wxStaticText(panel
, -1,
28 "Hello World!\nWhere is my menu?")
30 text
= wxStaticText(panel
, -1, "Hello World!")
31 text
.SetFont(wxFont(12, wxSWISS
, wxNORMAL
, wxBOLD
))
32 text
.SetSize(text
.GetBestSize())
33 btn
= wxButton(panel
, -1, "Close")
36 sizer
= wxBoxSizer(wxVERTICAL
)
37 sizer
.Add(text
, 0, wxALL
, 10)
38 sizer
.Add(btn
, 0, wxALL
, 10)
40 panel
.SetAutoLayout(true
)
43 EVT_BUTTON(self
, btn
.GetId(), self
.OnButton
)
46 def OnButton(self
, evt
):
47 """Event handler for the button click."""
52 frame
= MyFrame(None, "Simple wxPython App")