]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-11/realworld.py
3 class TestFrame(wx
.Frame
):
5 wx
.Frame
.__init
__(self
, None, -1, "Real World Test")
8 # First create the controls
9 topLbl
= wx
.StaticText(panel
, -1, "Account Information")
10 topLbl
.SetFont(wx
.Font(18, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
12 nameLbl
= wx
.StaticText(panel
, -1, "Name:")
13 name
= wx
.TextCtrl(panel
, -1, "");
15 addrLbl
= wx
.StaticText(panel
, -1, "Address:")
16 addr1
= wx
.TextCtrl(panel
, -1, "");
17 addr2
= wx
.TextCtrl(panel
, -1, "");
19 cstLbl
= wx
.StaticText(panel
, -1, "City, State, Zip:")
20 city
= wx
.TextCtrl(panel
, -1, "", size
=(150,-1));
21 state
= wx
.TextCtrl(panel
, -1, "", size
=(50,-1));
22 zip = wx
.TextCtrl(panel
, -1, "", size
=(70,-1));
24 phoneLbl
= wx
.StaticText(panel
, -1, "Phone:")
25 phone
= wx
.TextCtrl(panel
, -1, "");
27 emailLbl
= wx
.StaticText(panel
, -1, "Email:")
28 email
= wx
.TextCtrl(panel
, -1, "");
30 saveBtn
= wx
.Button(panel
, -1, "Save")
31 cancelBtn
= wx
.Button(panel
, -1, "Cancel")
35 # mainSizer is the top-level one that manages everything
36 mainSizer
= wx
.BoxSizer(wx
.VERTICAL
)
37 mainSizer
.Add(topLbl
, 0, wx
.ALL
, 5)
38 mainSizer
.Add(wx
.StaticLine(panel
), 0,
39 wx
.EXPAND|wx
.TOP|wx
.BOTTOM
, 5)
41 # addrSizer is a grid that holds all of the address info
42 addrSizer
= wx
.FlexGridSizer(cols
=2, hgap
=5, vgap
=5)
43 addrSizer
.AddGrowableCol(1)
44 addrSizer
.Add(nameLbl
, 0,
45 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
46 addrSizer
.Add(name
, 0, wx
.EXPAND
)
47 addrSizer
.Add(addrLbl
, 0,
48 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
49 addrSizer
.Add(addr1
, 0, wx
.EXPAND
)
50 addrSizer
.Add((10,10)) # some empty space
51 addrSizer
.Add(addr2
, 0, wx
.EXPAND
)
53 addrSizer
.Add(cstLbl
, 0,
54 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
56 # the city, state, zip fields are in a sub-sizer
57 cstSizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
59 cstSizer
.Add(state
, 0, wx
.LEFT|wx
.RIGHT
, 5)
61 addrSizer
.Add(cstSizer
, 0, wx
.EXPAND
)
63 addrSizer
.Add(phoneLbl
, 0,
64 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
65 addrSizer
.Add(phone
, 0, wx
.EXPAND
)
66 addrSizer
.Add(emailLbl
, 0,
67 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
68 addrSizer
.Add(email
, 0, wx
.EXPAND
)
70 # now add the addrSizer to the mainSizer
71 mainSizer
.Add(addrSizer
, 0, wx
.EXPAND|wx
.ALL
, 10)
73 # The buttons sizer will put them in a row with resizeable
74 # gaps between and on either side of the buttons
75 btnSizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
76 btnSizer
.Add((20,20), 1)
78 btnSizer
.Add((20,20), 1)
79 btnSizer
.Add(cancelBtn
)
80 btnSizer
.Add((20,20), 1)
82 mainSizer
.Add(btnSizer
, 0, wx
.EXPAND|wx
.BOTTOM
, 10)
84 panel
.SetSizer(mainSizer
)
86 # Fit the frame to the needs of the sizer. The frame will
87 # automatically resize the panel as needed. Also prevent the
88 # frame from getting smaller than this size.
90 mainSizer
.SetSizeHints(self
)
93 app
= wx
.PySimpleApp()