4 #----------------------------------------------------------------------
6 label1
= "Click here to show pane"
7 label2
= "Click here to hide pane"
9 btnlbl1
= "call Expand(True)"
10 btnlbl2
= "call Expand(False)"
13 class TestPanel(wx
.Panel
):
14 def __init__(self
, parent
, log
):
16 wx
.Panel
.__init
__(self
, parent
, -1)
18 title
= wx
.StaticText(self
, label
="wx.CollapsiblePane")
19 title
.SetFont(wx
.Font(18, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
20 title
.SetForegroundColour("blue")
22 self
.cp
= cp
= wx
.CollapsiblePane(self
, label
=label1
)
23 self
.Bind(wx
.EVT_COLLAPSIBLEPANE_CHANGED
, self
.OnPaneChanged
, cp
)
24 self
.MakePaneContent(cp
.GetPane())
26 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
28 sizer
.Add(title
, 0, wx
.ALL
, 25)
29 sizer
.Add(cp
, 0, wx
.RIGHT|wx
.LEFT|wx
.EXPAND
, 25)
31 self
.btn
= btn
= wx
.Button(self
, label
=btnlbl1
)
32 self
.Bind(wx
.EVT_BUTTON
, self
.OnToggle
, btn
)
33 sizer
.Add(btn
, 0, wx
.ALL
, 25)
36 def OnToggle(self
, evt
):
37 self
.cp
.Collapse(self
.cp
.IsExpanded())
41 def OnPaneChanged(self
, evt
=None):
43 self
.log
.write('wx.EVT_COLLAPSIBLEPANE_CHANGED: %s' % evt
.Collapsed
)
48 # and also change the labels
49 if self
.cp
.IsExpanded():
50 self
.cp
.SetLabel(label2
)
51 self
.btn
.SetLabel(btnlbl2
)
53 self
.cp
.SetLabel(label1
)
54 self
.btn
.SetLabel(btnlbl1
)
55 self
.btn
.SetInitialSize()
58 def MakePaneContent(self
, pane
):
59 '''Just make a few controls to put on the collapsible pane'''
60 nameLbl
= wx
.StaticText(pane
, -1, "Name:")
61 name
= wx
.TextCtrl(pane
, -1, "");
63 addrLbl
= wx
.StaticText(pane
, -1, "Address:")
64 addr1
= wx
.TextCtrl(pane
, -1, "");
65 addr2
= wx
.TextCtrl(pane
, -1, "");
67 cstLbl
= wx
.StaticText(pane
, -1, "City, State, Zip:")
68 city
= wx
.TextCtrl(pane
, -1, "", size
=(150,-1));
69 state
= wx
.TextCtrl(pane
, -1, "", size
=(50,-1));
70 zip = wx
.TextCtrl(pane
, -1, "", size
=(70,-1));
72 addrSizer
= wx
.FlexGridSizer(cols
=2, hgap
=5, vgap
=5)
73 addrSizer
.AddGrowableCol(1)
74 addrSizer
.Add(nameLbl
, 0,
75 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
76 addrSizer
.Add(name
, 0, wx
.EXPAND
)
77 addrSizer
.Add(addrLbl
, 0,
78 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
79 addrSizer
.Add(addr1
, 0, wx
.EXPAND
)
81 addrSizer
.Add(addr2
, 0, wx
.EXPAND
)
83 addrSizer
.Add(cstLbl
, 0,
84 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
86 cstSizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
88 cstSizer
.Add(state
, 0, wx
.LEFT|wx
.RIGHT
, 5)
90 addrSizer
.Add(cstSizer
, 0, wx
.EXPAND
)
92 border
= wx
.BoxSizer()
93 border
.Add(addrSizer
, 1, wx
.EXPAND|wx
.ALL
, 5)
98 #----------------------------------------------------------------------
100 def runTest(frame
, nb
, log
):
101 win
= TestPanel(nb
, log
)
104 #----------------------------------------------------------------------
108 overview
= """<html><body>
109 <h2><center>wx.CollapsiblePane</center></h2>
111 A collapsable panel is a container with an embedded button-like
112 control which can be used by the user to collapse or expand the pane's
120 if __name__
== '__main__':
123 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])