]>
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
):
11 def __init__(self
, parent
, title
):
12 wxFrame
.__init
__(self
, parent
, -1, title
, size
=(350, 200))
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
)
21 panel
= wxPanel(self
, -1)
22 if wxPlatform
== "__WXMAC__":
23 text
= wxStaticText(panel
, -1, "Hello World!\nWhere is my menu?")
25 text
= wxStaticText(panel
, -1, "Hello World!")
26 text
.SetFont(wxFont(12, wxSWISS
, wxNORMAL
, wxBOLD
))
27 text
.SetSize(text
.GetBestSize())
28 btn
= wxButton(panel
, -1, "Close")
31 sizer
= wxBoxSizer(wxVERTICAL
)
32 sizer
.Add(text
, 0, wxALL
, 10)
33 sizer
.Add(btn
, 0, wxALL
, 10)
35 panel
.SetAutoLayout(true
)
38 EVT_BUTTON(self
, btn
.GetId(), self
.OnButton
)
41 def OnButton(self
, evt
):
45 frame
= MyFrame(None, "Simple wxPython App")