]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-11/staticboxsizer.py
2 from blockwindow
import BlockWindow
4 labels
= "one two three four five six seven eight nine".split()
6 class TestFrame(wx
.Frame
):
8 wx
.Frame
.__init
__(self
, None, -1, "StaticBoxSizer Test")
9 self
.panel
= wx
.Panel(self
)
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])
16 # We can also use a sizer to manage the placement of other
17 # sizers (and therefore the windows and sub-sizers that they
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)
24 self
.panel
.SetSizer(sizer
)
28 def MakeStaticBoxSizer(self
, boxlabel
, itemlabels
):
29 # first the static box
30 box
= wx
.StaticBox(self
.panel
, -1, boxlabel
)
33 sizer
= wx
.StaticBoxSizer(box
, wx
.VERTICAL
)
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)
43 app
= wx
.PySimpleApp()