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):
42 self
.log
.write('wx.EVT_COLLAPSIBLEPANE_CHANGED')
44 if self
.cp
.IsExpanded():
45 self
.cp
.SetLabel(label2
)
46 self
.btn
.SetLabel(btnlbl2
)
48 self
.cp
.SetLabel(label1
)
49 self
.btn
.SetLabel(btnlbl1
)
50 self
.btn
.SetInitialSize()
53 def MakePaneContent(self
, pane
):
54 '''Just make a few controls to put on the collapsible pane'''
55 nameLbl
= wx
.StaticText(pane
, -1, "Name:")
56 name
= wx
.TextCtrl(pane
, -1, "");
58 addrLbl
= wx
.StaticText(pane
, -1, "Address:")
59 addr1
= wx
.TextCtrl(pane
, -1, "");
60 addr2
= wx
.TextCtrl(pane
, -1, "");
62 cstLbl
= wx
.StaticText(pane
, -1, "City, State, Zip:")
63 city
= wx
.TextCtrl(pane
, -1, "", size
=(150,-1));
64 state
= wx
.TextCtrl(pane
, -1, "", size
=(50,-1));
65 zip = wx
.TextCtrl(pane
, -1, "", size
=(70,-1));
67 addrSizer
= wx
.FlexGridSizer(cols
=2, hgap
=5, vgap
=5)
68 addrSizer
.Add((10,10))
69 addrSizer
.Add((10,10))
70 addrSizer
.AddGrowableCol(1)
71 addrSizer
.Add(nameLbl
, 0,
72 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
73 addrSizer
.Add(name
, 0, wx
.EXPAND
)
74 addrSizer
.Add(addrLbl
, 0,
75 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
76 addrSizer
.Add(addr1
, 0, wx
.EXPAND
)
77 addrSizer
.Add((10,10))
78 addrSizer
.Add(addr2
, 0, wx
.EXPAND
)
80 addrSizer
.Add(cstLbl
, 0,
81 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
83 cstSizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
85 cstSizer
.Add(state
, 0, wx
.LEFT|wx
.RIGHT
, 5)
87 addrSizer
.Add(cstSizer
, 0, wx
.EXPAND
)
89 pane
.SetSizer(addrSizer
)
93 #----------------------------------------------------------------------
95 def runTest(frame
, nb
, log
):
96 win
= TestPanel(nb
, log
)
99 #----------------------------------------------------------------------
103 overview
= """<html><body>
104 <h2><center>wx.CollapsiblePane</center></h2>
106 A collapsable panel is a container with an embedded button-like
107 control which can be used by the user to collapse or expand the pane's
115 if __name__
== '__main__':
118 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])