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                                           style
=wx
.CP_DEFAULT_STYLE|wx
.CP_NO_TLW_RESIZE
) 
  24         self
.Bind(wx
.EVT_COLLAPSIBLEPANE_CHANGED
, self
.OnPaneChanged
, cp
) 
  25         self
.MakePaneContent(cp
.GetPane()) 
  27         sizer 
= wx
.BoxSizer(wx
.VERTICAL
) 
  29         sizer
.Add(title
, 0, wx
.ALL
, 25) 
  30         sizer
.Add(cp
, 0, wx
.RIGHT|wx
.LEFT|wx
.EXPAND
, 25) 
  32         self
.btn 
= btn 
= wx
.Button(self
, label
=btnlbl1
) 
  33         self
.Bind(wx
.EVT_BUTTON
, self
.OnToggle
, btn
) 
  34         sizer
.Add(btn
, 0, wx
.ALL
, 25) 
  37     def OnToggle(self
, evt
): 
  38         self
.cp
.Collapse(self
.cp
.IsExpanded()) 
  42     def OnPaneChanged(self
, evt
=None): 
  44             self
.log
.write('wx.EVT_COLLAPSIBLEPANE_CHANGED: %s' % evt
.Collapsed
) 
  49         # and also change the labels 
  50         if self
.cp
.IsExpanded(): 
  51             self
.cp
.SetLabel(label2
) 
  52             self
.btn
.SetLabel(btnlbl2
) 
  54             self
.cp
.SetLabel(label1
) 
  55             self
.btn
.SetLabel(btnlbl1
) 
  56         self
.btn
.SetInitialSize() 
  59     def MakePaneContent(self
, pane
): 
  60         '''Just make a few controls to put on the collapsible pane''' 
  61         nameLbl 
= wx
.StaticText(pane
, -1, "Name:") 
  62         name 
= wx
.TextCtrl(pane
, -1, ""); 
  64         addrLbl 
= wx
.StaticText(pane
, -1, "Address:") 
  65         addr1 
= wx
.TextCtrl(pane
, -1, ""); 
  66         addr2 
= wx
.TextCtrl(pane
, -1, ""); 
  68         cstLbl 
= wx
.StaticText(pane
, -1, "City, State, Zip:") 
  69         city  
= wx
.TextCtrl(pane
, -1, "", size
=(150,-1)); 
  70         state 
= wx
.TextCtrl(pane
, -1, "", size
=(50,-1)); 
  71         zip   = wx
.TextCtrl(pane
, -1, "", size
=(70,-1)); 
  73         addrSizer 
= wx
.FlexGridSizer(cols
=2, hgap
=5, vgap
=5) 
  74         addrSizer
.AddGrowableCol(1) 
  75         addrSizer
.Add(nameLbl
, 0,  
  76                 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
) 
  77         addrSizer
.Add(name
, 0, wx
.EXPAND
) 
  78         addrSizer
.Add(addrLbl
, 0, 
  79                 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
) 
  80         addrSizer
.Add(addr1
, 0, wx
.EXPAND
) 
  82         addrSizer
.Add(addr2
, 0, wx
.EXPAND
) 
  84         addrSizer
.Add(cstLbl
, 0, 
  85                 wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
) 
  87         cstSizer 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
  89         cstSizer
.Add(state
, 0, wx
.LEFT|wx
.RIGHT
, 5) 
  91         addrSizer
.Add(cstSizer
, 0, wx
.EXPAND
) 
  93         border 
= wx
.BoxSizer() 
  94         border
.Add(addrSizer
, 1, wx
.EXPAND|wx
.ALL
, 5) 
  99 #---------------------------------------------------------------------- 
 101 def runTest(frame
, nb
, log
): 
 102     win 
= TestPanel(nb
, log
) 
 105 #---------------------------------------------------------------------- 
 109 overview 
= """<html><body> 
 110 <h2><center>wx.CollapsiblePane</center></h2> 
 112 A collapsable panel is a container with an embedded button-like 
 113 control which can be used by the user to collapse or expand the pane's 
 121 if __name__ 
== '__main__': 
 124     run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])