Attachment 'boxsize.py'
Download 1 import wx
2
3 class MyForm(wx.Frame):
4
5 def __init__(self):
6 wx.Frame.__init__(self, None, wx.ID_ANY, title="My Form")
7
8 # Add a panel so it looks correct on all platforms
9 self.panel = wx.Panel(self, wx.ID_ANY)
10
11 bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_OTHER, (16, 16))
12 titleIco = wx.StaticBitmap(self.panel, wx.ID_ANY, bmp)
13 title = wx.StaticText(self.panel, wx.ID_ANY, 'BoxSizer')
14
15 bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_OTHER, (16, 16))
16
17 inputOneIco = wx.StaticBitmap(self.panel, wx.ID_ANY, bmp)
18 labelOne = wx.StaticText(self.panel, wx.ID_ANY, 'Input 1')
19 inputTxtOne = wx.TextCtrl(self.panel, wx.ID_ANY)
20
21 inputTwoIco = wx.StaticBitmap(self.panel, wx.ID_ANY, bmp)
22 labelTwo = wx.StaticText(self.panel, wx.ID_ANY, 'Input 2')
23 inputTxtTwo = wx.TextCtrl(self.panel, wx.ID_ANY)
24
25 inputThreeIco = wx.StaticBitmap(self.panel, wx.ID_ANY, bmp)
26 labelThree = wx.StaticText(self.panel, wx.ID_ANY, 'Input 3')
27 inputTxtThree = wx.TextCtrl(self.panel, wx.ID_ANY)
28
29 inputFourIco = wx.StaticBitmap(self.panel, wx.ID_ANY, bmp)
30 labelFour = wx.StaticText(self.panel, wx.ID_ANY, 'Input 4')
31 inputTxtFour = wx.TextCtrl(self.panel, wx.ID_ANY)
32
33 okBtn = wx.Button(self.panel, wx.ID_ANY, 'OK')
34 cancelBtn = wx.Button(self.panel, wx.ID_ANY, 'Cancel')
35
36 topSizer = wx.BoxSizer(wx.VERTICAL)
37 titleSizer = wx.BoxSizer(wx.HORIZONTAL)
38 inputOneSizer = wx.BoxSizer(wx.HORIZONTAL)
39 inputTwoSizer = wx.BoxSizer(wx.HORIZONTAL)
40 inputThreeSizer = wx.BoxSizer(wx.HORIZONTAL)
41 inputFourSizer = wx.BoxSizer(wx.HORIZONTAL)
42 btnSizer = wx.BoxSizer(wx.HORIZONTAL)
43
44 titleSizer.Add(titleIco, 0, wx.ALL, 5)
45 titleSizer.Add(title, 0, wx.ALL, 5)
46
47 inputOneSizer.Add(inputOneIco, 0, wx.ALL, 5)
48 inputOneSizer.Add(labelOne, 0, wx.ALL, 5)
49 inputOneSizer.Add(inputTxtOne, 1, wx.ALL|wx.EXPAND, 5)
50
51 inputTwoSizer.Add(inputTwoIco, 0, wx.ALL, 5)
52 inputTwoSizer.Add(labelTwo, 0, wx.ALL, 5)
53 inputTwoSizer.Add(inputTxtTwo, 1, wx.ALL|wx.EXPAND, 5)
54
55 inputThreeSizer.Add(inputThreeIco, 0, wx.ALL, 5)
56 inputThreeSizer.Add(labelThree, 0, wx.ALL, 5)
57 inputThreeSizer.Add(inputTxtThree, 1, wx.ALL|wx.EXPAND, 5)
58
59 inputFourSizer.Add(inputFourIco, 0, wx.ALL, 5)
60 inputFourSizer.Add(labelFour, 0, wx.ALL, 5)
61 inputFourSizer.Add(inputTxtFour, 1, wx.ALL|wx.EXPAND, 5)
62
63 btnSizer.Add(okBtn, 0, wx.ALL, 5)
64 btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
65
66 topSizer.Add(titleSizer, 0, wx.CENTER)
67 topSizer.Add(wx.StaticLine(self.panel,), 0, wx.ALL|wx.EXPAND, 5)
68 topSizer.Add(inputOneSizer, 0, wx.ALL|wx.EXPAND, 5)
69 topSizer.Add(inputTwoSizer, 0, wx.ALL|wx.EXPAND, 5)
70 topSizer.Add(inputThreeSizer, 0, wx.ALL|wx.EXPAND, 5)
71 topSizer.Add(inputFourSizer, 0, wx.ALL|wx.EXPAND, 5)
72 topSizer.Add(wx.StaticLine(self.panel), 0, wx.ALL|wx.EXPAND, 5)
73 topSizer.Add(btnSizer, 0, wx.ALL|wx.CENTER, 5)
74
75 self.panel.SetSizer(topSizer)
76 topSizer.Fit(self)
77 if __name__ == "__main__":
78 app = wx.PySimpleApp()
79 frame = MyForm().Show()
80 app.MainLoop()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.