]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-11/staticboxsizer.py
fix building/running of tex2rtf
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-11 / staticboxsizer.py
1 import wx
2 from blockwindow import BlockWindow
3
4 labels = "one two three four five six seven eight nine".split()
5
6 class TestFrame(wx.Frame):
7 def __init__(self):
8 wx.Frame.__init__(self, None, -1, "StaticBoxSizer Test")
9 self.panel = wx.Panel(self)
10
11 # make three static boxes with windows positioned inside them
12 box1 = self.MakeStaticBoxSizer("Box 1", labels[0:3])
13 box2 = self.MakeStaticBoxSizer("Box 2", labels[3:6])
14 box3 = self.MakeStaticBoxSizer("Box 3", labels[6:9])
15
16 # We can also use a sizer to manage the placement of other
17 # sizers (and therefore the windows and sub-sizers that they
18 # manage as well.)
19 sizer = wx.BoxSizer(wx.HORIZONTAL)
20 sizer.Add(box1, 0, wx.ALL, 10)
21 sizer.Add(box2, 0, wx.ALL, 10)
22 sizer.Add(box3, 0, wx.ALL, 10)
23
24 self.panel.SetSizer(sizer)
25 sizer.Fit(self)
26
27
28 def MakeStaticBoxSizer(self, boxlabel, itemlabels):
29 # first the static box
30 box = wx.StaticBox(self.panel, -1, boxlabel)
31
32 # then the sizer
33 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
34
35 # then add items to it like normal
36 for label in itemlabels:
37 bw = BlockWindow(self.panel, label=label)
38 sizer.Add(bw, 0, wx.ALL, 2)
39
40 return sizer
41
42
43 app = wx.PySimpleApp()
44 TestFrame().Show()
45 app.MainLoop()