]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-11/realworld.py
don't use invalid wxIconBundles, it results in asserts after recent changes
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-11 / realworld.py
1 import wx
2
3 class TestFrame(wx.Frame):
4 def __init__(self):
5 wx.Frame.__init__(self, None, -1, "Real World Test")
6 panel = wx.Panel(self)
7
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))
11
12 nameLbl = wx.StaticText(panel, -1, "Name:")
13 name = wx.TextCtrl(panel, -1, "");
14
15 addrLbl = wx.StaticText(panel, -1, "Address:")
16 addr1 = wx.TextCtrl(panel, -1, "");
17 addr2 = wx.TextCtrl(panel, -1, "");
18
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));
23
24 phoneLbl = wx.StaticText(panel, -1, "Phone:")
25 phone = wx.TextCtrl(panel, -1, "");
26
27 emailLbl = wx.StaticText(panel, -1, "Email:")
28 email = wx.TextCtrl(panel, -1, "");
29
30 saveBtn = wx.Button(panel, -1, "Save")
31 cancelBtn = wx.Button(panel, -1, "Cancel")
32
33 # Now do the layout.
34
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)
40
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)
52
53 addrSizer.Add(cstLbl, 0,
54 wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
55
56 # the city, state, zip fields are in a sub-sizer
57 cstSizer = wx.BoxSizer(wx.HORIZONTAL)
58 cstSizer.Add(city, 1)
59 cstSizer.Add(state, 0, wx.LEFT|wx.RIGHT, 5)
60 cstSizer.Add(zip)
61 addrSizer.Add(cstSizer, 0, wx.EXPAND)
62
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)
69
70 # now add the addrSizer to the mainSizer
71 mainSizer.Add(addrSizer, 0, wx.EXPAND|wx.ALL, 10)
72
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)
77 btnSizer.Add(saveBtn)
78 btnSizer.Add((20,20), 1)
79 btnSizer.Add(cancelBtn)
80 btnSizer.Add((20,20), 1)
81
82 mainSizer.Add(btnSizer, 0, wx.EXPAND|wx.BOTTOM, 10)
83
84 panel.SetSizer(mainSizer)
85
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.
89 mainSizer.Fit(self)
90 mainSizer.SetSizeHints(self)
91
92
93 app = wx.PySimpleApp()
94 TestFrame().Show()
95 app.MainLoop()