1 # 11/26/2003 - Jeff Grimmett (grimmtooth@softhome.net) 
   3 # o Had to do a bit of rework for the demo; there was no panel attached 
   4 #   to the demo window, so all buttons were showing as dark gray on 
   5 #   dark gray. I have no idea why this didn't break before. Robin, 
   6 #   please examine my changes to ensure you approve. It's rather 
  10 #---------------------------------------------------------------------- 
  12 #---------------------------------------------------------------------- 
  16 #---------------------------------------------------------------------- 
  18 class SampleWindow(wx
.PyWindow
): 
  20     A simple window that is used as sizer items in the tests below to 
  21     show how the various sizers work. 
  23     def __init__(self
, parent
, text
, pos
=wx
.DefaultPosition
, size
=wx
.DefaultSize
): 
  24         wx
.PyWindow
.__init
__(self
, parent
, -1, 
  25                              #style=wx.RAISED_BORDER 
  26                              #style=wx.SUNKEN_BORDER 
  27                              style
=wx
.SIMPLE_BORDER
 
  30         if size 
!= wx
.DefaultSize
: 
  33             self
.bestsize 
= (80,25) 
  34         self
.SetSize(self
.GetBestSize()) 
  36         self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
) 
  37         self
.Bind(wx
.EVT_SIZE
, self
.OnSize
) 
  38         self
.Bind(wx
.EVT_LEFT_UP
, self
.OnCloseParent
) 
  41     def OnPaint(self
, evt
): 
  44         w
,h 
= dc
.GetTextExtent(self
.text
) 
  46         dc
.DrawText(self
.text
, (sz
.width
-w
)/2, (sz
.height
-h
)/2) 
  48     def OnSize(self
, evt
): 
  51     def OnCloseParent(self
, evt
): 
  52         p 
= wx
.GetTopLevelParent(self
) 
  56     def DoGetBestSize(self
): 
  60 #---------------------------------------------------------------------- 
  62 def makeSimpleBox1(win
): 
  63     box 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
  64     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
  65     box
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
  66     box
.Add(SampleWindow(win
, "three"), 0, wx
.EXPAND
) 
  67     box
.Add(SampleWindow(win
, "four"), 0, wx
.EXPAND
) 
  71 #---------------------------------------------------------------------- 
  73 def makeSimpleBox2(win
): 
  74     box 
= wx
.BoxSizer(wx
.VERTICAL
) 
  75     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
  76     box
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
  77     box
.Add(SampleWindow(win
, "three"), 0, wx
.EXPAND
) 
  78     box
.Add(SampleWindow(win
, "four"), 0, wx
.EXPAND
) 
  82 #---------------------------------------------------------------------- 
  84 def makeSimpleBox3(win
): 
  85     box 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
  86     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
  87     box
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
  88     box
.Add(SampleWindow(win
, "three"), 0, wx
.EXPAND
) 
  89     box
.Add(SampleWindow(win
, "four"), 0, wx
.EXPAND
) 
  90     box
.Add(SampleWindow(win
, "five"), 1, wx
.EXPAND
) 
  94 #---------------------------------------------------------------------- 
  96 def makeSimpleBox4(win
): 
  97     box 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
  98     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
  99     box
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
 100     box
.Add(SampleWindow(win
, "three"), 1, wx
.EXPAND
) 
 101     box
.Add(SampleWindow(win
, "four"), 1, wx
.EXPAND
) 
 102     box
.Add(SampleWindow(win
, "five"), 1, wx
.EXPAND
) 
 106 #---------------------------------------------------------------------- 
 108 def makeSimpleBox5(win
): 
 109     box 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 110     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
 111     box
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
 112     box
.Add(SampleWindow(win
, "three"), 3, wx
.EXPAND
) 
 113     box
.Add(SampleWindow(win
, "four"), 1, wx
.EXPAND
) 
 114     box
.Add(SampleWindow(win
, "five"), 1, wx
.EXPAND
) 
 118 #---------------------------------------------------------------------- 
 120 def makeSimpleBox6(win
): 
 121     box 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 122     box
.Add(SampleWindow(win
, "one"), 1, wx
.ALIGN_TOP
) 
 123     box
.Add(SampleWindow(win
, "two"), 1, wx
.EXPAND
) 
 124     box
.Add(SampleWindow(win
, "three"), 1, wx
.ALIGN_CENTER
) 
 125     box
.Add(SampleWindow(win
, "four"), 1, wx
.EXPAND
) 
 126     box
.Add(SampleWindow(win
, "five"), 1, wx
.ALIGN_BOTTOM
) 
 130 #---------------------------------------------------------------------- 
 132 def makeSimpleBox7(win
): 
 133     box 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 134     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
 135     box
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
 136     box
.Add(SampleWindow(win
, "three"), 0, wx
.EXPAND
) 
 137     box
.Add((60, 20), 0, wx
.EXPAND
) 
 138     box
.Add(SampleWindow(win
, "five"), 1, wx
.EXPAND
) 
 142 #---------------------------------------------------------------------- 
 144 def makeSimpleBox8(win
): 
 145     box 
= wx
.BoxSizer(wx
.VERTICAL
) 
 146     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
 148     box
.Add(SampleWindow(win
, "two"), 0, wx
.ALIGN_CENTER
) 
 150     box
.Add(SampleWindow(win
, "three"), 0, wx
.EXPAND
) 
 151     box
.Add(SampleWindow(win
, "four"), 0, wx
.EXPAND
) 
 152 #    box.Add(SampleWindow(win, "five"), 1, wx.EXPAND) 
 156 #---------------------------------------------------------------------- 
 157 #---------------------------------------------------------------------- 
 159 def makeSimpleBorder1(win
): 
 160     bdr 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 161     btn 
= SampleWindow(win
, "border") 
 162     btn
.SetSize((80, 80)) 
 163     bdr
.Add(btn
, 1, wx
.EXPAND|wx
.ALL
, 15) 
 167 #---------------------------------------------------------------------- 
 169 def makeSimpleBorder2(win
): 
 170     bdr 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 171     btn 
= SampleWindow(win
, "border") 
 172     btn
.SetSize((80, 80)) 
 173     bdr
.Add(btn
, 1, wx
.EXPAND | wx
.EAST | wx
.WEST
, 15) 
 177 #---------------------------------------------------------------------- 
 179 def makeSimpleBorder3(win
): 
 180     bdr 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 181     btn 
= SampleWindow(win
, "border") 
 182     btn
.SetSize((80, 80)) 
 183     bdr
.Add(btn
, 1, wx
.EXPAND | wx
.NORTH | wx
.WEST
, 15) 
 187 #---------------------------------------------------------------------- 
 188 #---------------------------------------------------------------------- 
 190 def makeBoxInBox(win
): 
 191     box 
= wx
.BoxSizer(wx
.VERTICAL
) 
 193     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
 195     box2 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 196     box2
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
 197     btn3 
= SampleWindow(win
, "three") 
 198     box2
.Add(btn3
, 0, wx
.EXPAND
) 
 199     box2
.Add(SampleWindow(win
, "four"), 0, wx
.EXPAND
) 
 200     box2
.Add(SampleWindow(win
, "five"), 0, wx
.EXPAND
) 
 202     box3 
= wx
.BoxSizer(wx
.VERTICAL
) 
 203     box3
.AddMany([ (SampleWindow(win
, "six"),   0, wx
.EXPAND
), 
 204                    (SampleWindow(win
, "seven"), 2, wx
.EXPAND
), 
 205                    (SampleWindow(win
, "eight"), 1, wx
.EXPAND
), 
 206                    (SampleWindow(win
, "nine"),  1, wx
.EXPAND
), 
 209     box2
.Add(box3
, 1, wx
.EXPAND
) 
 210     box
.Add(box2
, 1, wx
.EXPAND
) 
 212     box
.Add(SampleWindow(win
, "ten"), 0, wx
.EXPAND
) 
 218 #---------------------------------------------------------------------- 
 220 def makeBoxInBorder(win
): 
 221     bdr 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 222     box 
= makeSimpleBox3(win
) 
 223     bdr
.Add(box
, 1, wx
.EXPAND | wx
.ALL
, 15) 
 227 #---------------------------------------------------------------------- 
 229 def makeBorderInBox(win
): 
 230     insideBox 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 232     box2 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 233     box2
.AddMany([ (SampleWindow(win
, "one"), 0, wx
.EXPAND
), 
 234                    (SampleWindow(win
, "two"), 0, wx
.EXPAND
), 
 235                    (SampleWindow(win
, "three"), 0, wx
.EXPAND
), 
 236                    (SampleWindow(win
, "four"), 0, wx
.EXPAND
), 
 237                    (SampleWindow(win
, "five"), 0, wx
.EXPAND
), 
 240     insideBox
.Add(box2
, 0, wx
.EXPAND
) 
 242     bdr 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 243     bdr
.Add(SampleWindow(win
, "border"), 1, wx
.EXPAND | wx
.ALL
) 
 244     insideBox
.Add(bdr
, 1, wx
.EXPAND | wx
.ALL
, 20) 
 246     box3 
= wx
.BoxSizer(wx
.VERTICAL
) 
 247     box3
.AddMany([ (SampleWindow(win
, "six"),   0, wx
.EXPAND
), 
 248                    (SampleWindow(win
, "seven"), 2, wx
.EXPAND
), 
 249                    (SampleWindow(win
, "eight"), 1, wx
.EXPAND
), 
 250                    (SampleWindow(win
, "nine"),  1, wx
.EXPAND
), 
 252     insideBox
.Add(box3
, 1, wx
.EXPAND
) 
 254     outsideBox 
= wx
.BoxSizer(wx
.VERTICAL
) 
 255     outsideBox
.Add(SampleWindow(win
, "top"), 0, wx
.EXPAND
) 
 256     outsideBox
.Add(insideBox
, 1, wx
.EXPAND
) 
 257     outsideBox
.Add(SampleWindow(win
, "bottom"), 0, wx
.EXPAND
) 
 262 #---------------------------------------------------------------------- 
 265     gs 
= wx
.GridSizer(3, 3, 2, 2)  # rows, cols, hgap, vgap 
 267     gs
.AddMany([ (SampleWindow(win
, 'one'),   0, wx
.EXPAND
), 
 268                  (SampleWindow(win
, 'two'),   0, wx
.EXPAND
), 
 269                  (SampleWindow(win
, 'three'), 0, wx
.EXPAND
), 
 270                  (SampleWindow(win
, 'four'),  0, wx
.EXPAND
), 
 271                  (SampleWindow(win
, 'five'),  0, wx
.EXPAND
), 
 273                  (SampleWindow(win
, 'six'),   0, wx
.EXPAND
), 
 274                  (SampleWindow(win
, 'seven'), 0, wx
.EXPAND
), 
 275                  (SampleWindow(win
, 'eight'), 0, wx
.EXPAND
), 
 276                  (SampleWindow(win
, 'nine'),  0, wx
.EXPAND
), 
 281 #---------------------------------------------------------------------- 
 284     gs 
= wx
.GridSizer(3, 3)  # rows, cols, hgap, vgap 
 286     box 
= wx
.BoxSizer(wx
.VERTICAL
) 
 287     box
.Add(SampleWindow(win
, 'A'), 0, wx
.EXPAND
) 
 288     box
.Add(SampleWindow(win
, 'B'), 1, wx
.EXPAND
) 
 290     gs2 
= wx
.GridSizer(2,2, 4, 4) 
 291     gs2
.AddMany([ (SampleWindow(win
, 'C'), 0, wx
.EXPAND
), 
 292                   (SampleWindow(win
, 'E'), 0, wx
.EXPAND
), 
 293                   (SampleWindow(win
, 'F'), 0, wx
.EXPAND
), 
 294                   (SampleWindow(win
, 'G'), 0, wx
.EXPAND
)]) 
 296     gs
.AddMany([ (SampleWindow(win
, 'one'),   0, wx
.ALIGN_RIGHT | wx
.ALIGN_BOTTOM
), 
 297                  (SampleWindow(win
, 'two'),   0, wx
.EXPAND
), 
 298                  (SampleWindow(win
, 'three'), 0, wx
.ALIGN_LEFT | wx
.ALIGN_BOTTOM
), 
 299                  (SampleWindow(win
, 'four'),  0, wx
.EXPAND
), 
 300                  (SampleWindow(win
, 'five'),  0, wx
.ALIGN_CENTER
), 
 301                  (SampleWindow(win
, 'six'),   0, wx
.EXPAND
), 
 302                  (box
,                          0, wx
.EXPAND | wx
.ALL
, 10), 
 303                  (SampleWindow(win
, 'eight'), 0, wx
.EXPAND
), 
 304                  (gs2
,                          0, wx
.EXPAND | wx
.ALL
, 4), 
 309 #---------------------------------------------------------------------- 
 312     gs 
= wx
.FlexGridSizer(3, 3, 2, 2)  # rows, cols, hgap, vgap 
 314     gs
.AddMany([ (SampleWindow(win
, 'one'),   0, wx
.EXPAND
), 
 315                  (SampleWindow(win
, 'two'),   0, wx
.EXPAND
), 
 316                  (SampleWindow(win
, 'three'), 0, wx
.EXPAND
), 
 317                  (SampleWindow(win
, 'four'),  0, wx
.EXPAND
), 
 318                  #(SampleWindow(win, 'five'),  0, wx.EXPAND), 
 320                  (SampleWindow(win
, 'six'),   0, wx
.EXPAND
), 
 321                  (SampleWindow(win
, 'seven'), 0, wx
.EXPAND
), 
 322                  (SampleWindow(win
, 'eight'), 0, wx
.EXPAND
), 
 323                  (SampleWindow(win
, 'nine'),  0, wx
.EXPAND
), 
 331 #---------------------------------------------------------------------- 
 334     bpos 
= wx
.DefaultPosition
 
 335     bsize 
= wx
.Size(100, 50) 
 336     gs 
= wx
.GridSizer(3, 3, 2, 2)  # rows, cols, hgap, vgap 
 338     gs
.AddMany([ (SampleWindow(win
, 'one', bpos
, bsize
), 
 339                   0, wx
.ALIGN_TOP | wx
.ALIGN_LEFT 
), 
 340                  (SampleWindow(win
, 'two', bpos
, bsize
), 
 341                   0, wx
.ALIGN_TOP | wx
.ALIGN_CENTER_HORIZONTAL 
), 
 342                  (SampleWindow(win
, 'three', bpos
, bsize
), 
 343                   0, wx
.ALIGN_TOP | wx
.ALIGN_RIGHT 
), 
 344                  (SampleWindow(win
, 'four', bpos
, bsize
), 
 345                   0, wx
.ALIGN_CENTER_VERTICAL | wx
.ALIGN_LEFT 
), 
 346                  (SampleWindow(win
, 'five', bpos
, bsize
), 
 347                   0, wx
.ALIGN_CENTER 
), 
 348                  (SampleWindow(win
, 'six', bpos
, bsize
), 
 349                   0, wx
.ALIGN_CENTER_VERTICAL | wx
.ALIGN_RIGHT 
), 
 350                  (SampleWindow(win
, 'seven', bpos
, bsize
), 
 351                   0, wx
.ALIGN_BOTTOM | wx
.ALIGN_LEFT 
), 
 352                  (SampleWindow(win
, 'eight', bpos
, bsize
), 
 353                   0, wx
.ALIGN_BOTTOM | wx
.ALIGN_CENTER_HORIZONTAL 
), 
 354                  (SampleWindow(win
, 'nine', bpos
, bsize
), 
 355                   0, wx
.ALIGN_BOTTOM | wx
.ALIGN_RIGHT 
), 
 360 #---------------------------------------------------------------------- 
 363     bpos 
= wx
.DefaultPosition
 
 364     bsize 
= wx
.Size(100, 50) 
 365     gs 
= wx
.GridSizer(3, 3, 2, 2)  # rows, cols, hgap, vgap 
 367     gs
.AddMany([ (SampleWindow(win
, 'one', bpos
, bsize
), 
 368                   0, wx
.SHAPED | wx
.ALIGN_TOP | wx
.ALIGN_LEFT 
), 
 369                  (SampleWindow(win
, 'two', bpos
, bsize
), 
 370                   0, wx
.SHAPED | wx
.ALIGN_TOP | wx
.ALIGN_CENTER_HORIZONTAL 
), 
 371                  (SampleWindow(win
, 'three', bpos
, bsize
), 
 372                   0, wx
.SHAPED | wx
.ALIGN_TOP | wx
.ALIGN_RIGHT 
), 
 373                  (SampleWindow(win
, 'four', bpos
, bsize
), 
 374                   0, wx
.SHAPED | wx
.ALIGN_CENTER_VERTICAL | wx
.ALIGN_LEFT 
), 
 375                  (SampleWindow(win
, 'five', bpos
, bsize
), 
 376                   0, wx
.SHAPED | wx
.ALIGN_CENTER 
), 
 377                  (SampleWindow(win
, 'six', bpos
, bsize
), 
 378                   0, wx
.SHAPED | wx
.ALIGN_CENTER_VERTICAL | wx
.ALIGN_RIGHT 
), 
 379                  (SampleWindow(win
, 'seven', bpos
, bsize
), 
 380                   0, wx
.SHAPED |  wx
.ALIGN_BOTTOM | wx
.ALIGN_LEFT 
), 
 381                  (SampleWindow(win
, 'eight', bpos
, bsize
), 
 382                   0, wx
.SHAPED | wx
.ALIGN_BOTTOM | wx
.ALIGN_CENTER_HORIZONTAL 
), 
 383                  (SampleWindow(win
, 'nine', bpos
, bsize
), 
 384                   0, wx
.SHAPED | wx
.ALIGN_BOTTOM | wx
.ALIGN_RIGHT 
), 
 389 #---------------------------------------------------------------------- 
 391 def makeSimpleBoxShaped(win
): 
 392     box 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
 393     box
.Add(SampleWindow(win
, "one"), 0, wx
.EXPAND
) 
 394     box
.Add(SampleWindow(win
, "two"), 0, wx
.EXPAND
) 
 395     box
.Add(SampleWindow(win
, "three"), 0, wx
.EXPAND
) 
 396     box
.Add(SampleWindow(win
, "four"), 0, wx
.EXPAND
) 
 397     box
.Add(SampleWindow(win
, "five"), 1, wx
.SHAPED
) 
 401 #---------------------------------------------------------------------- 
 404     ("Simple horizontal boxes", makeSimpleBox1
, 
 405      "This is a HORIZONTAL box sizer with four non-stretchable buttons held " 
 406      "within it.  Notice that the buttons are added and aligned in the horizontal " 
 407      "dimension.  Also notice that they are fixed size in the horizontal dimension, " 
 408      "but will stretch vertically." 
 411     ("Simple vertical boxes", makeSimpleBox2
, 
 412      "Exactly the same as the previous sample but using a VERTICAL box sizer " 
 413      "instead of a HORIZONTAL one." 
 416     ("Add a stretchable", makeSimpleBox3
, 
 417      "We've added one more button with the stretchable flag turned on.  Notice " 
 418      "how it grows to fill the extra space in the otherwise fixed dimension." 
 421     ("More than one stretchable", makeSimpleBox4
, 
 422      "Here there are several items that are stretchable, they all divide up the " 
 423      "extra space evenly." 
 426     ("Weighting factor", makeSimpleBox5
, 
 427      "This one shows more than one stretchable, but one of them has a weighting " 
 428      "factor so it gets more of the free space." 
 431     ("Edge Affinity", makeSimpleBox6
, 
 432      "For items that don't completly fill their allotted space, and don't " 
 433      "stretch, you can specify which side (or the center) they should stay " 
 437     ("Spacer", makeSimpleBox7
, 
 438      "You can add empty space to be managed by a Sizer just as if it were a " 
 439      "window or another Sizer." 
 442     ("Centering in available space", makeSimpleBox8
, 
 443      "This one shows an item that does not expand to fill it's space, but rather" 
 444      "stays centered within it." 
 447 #    ("Percent Sizer", makeSimpleBox6, 
 448 #     "You can use the wx.BoxSizer like a Percent Sizer.  Just make sure that all " 
 449 #     "the weighting factors add up to 100!" 
 454     ("Simple border sizer", makeSimpleBorder1
, 
 455      "The wx.BoxSizer can leave empty space around its contents.  This one " 
 456      "gives a border all the way around." 
 459     ("East and West border", makeSimpleBorder2
, 
 460      "You can pick and choose which sides have borders." 
 463     ("North and West border", makeSimpleBorder3
, 
 464      "You can pick and choose which sides have borders." 
 469     ("Boxes inside of boxes", makeBoxInBox
, 
 470      "This one shows nesting of boxes within boxes within boxes, using both " 
 471      "orientations.  Notice also that button seven has a greater weighting " 
 472      "factor than its siblings." 
 475     ("Boxes inside a Border", makeBoxInBorder
, 
 476      "Sizers of different types can be nested within each other as well. " 
 477      "Here is a box sizer with several buttons embedded within a border sizer." 
 480     ("Border in a Box", makeBorderInBox
, 
 481      "Another nesting example.  This one has Boxes and a Border inside another Box." 
 486     ("Simple Grid", makeGrid1
, 
 487      "This is an example of the wx.GridSizer.  In this case all row heights " 
 488      "and column widths are kept the same as all the others and all items " 
 489      "fill their available space.  The horizontal and vertical gaps are set to " 
 493     ("More Grid Features", makeGrid2
, 
 494      "This is another example of the wx.GridSizer.  This one has no gaps in the grid, " 
 495      "but various cells are given different alignment options and some of them " 
 496      "hold nested sizers." 
 499     ("Flexible Grid", makeGrid3
, 
 500      "This grid allows the rows to have different heights and the columns to have " 
 501      "different widths.  You can also specify rows and columns that are growable, " 
 502      "which we have done for the first and last row and the middle column for " 
 504      "\nThere is also a spacer in the middle cell instead of an actual window." 
 507     ("Grid with Alignment", makeGrid4
, 
 508      "New alignment flags allow for the positioning of items in any corner or centered " 
 514     ("Proportional resize", makeSimpleBoxShaped
, 
 515      "Managed items can preserve their original aspect ratio.  The last item has the " 
 516      "wx.SHAPED flag set and will resize proportional to its original size." 
 519     ("Proportional resize with Alignments", makeShapes
, 
 520      "This one shows various alignments as well as proportional resizing for all items." 
 524 #---------------------------------------------------------------------- 
 526 class TestFrame(wx
.Frame
): 
 527     def __init__(self
, parent
, title
, sizerFunc
): 
 528         wx
.Frame
.__init
__(self
, parent
, -1, title
) 
 530         p 
= wx
.Panel(self
, -1) 
 532         self
.sizer 
= sizerFunc(p
) 
 533         self
.CreateStatusBar() 
 534         self
.SetStatusText("Resize this frame to see how the sizers respond...") 
 536         p
.SetSizer(self
.sizer
) 
 538         self
.Bind(wx
.EVT_CLOSE
, self
.OnCloseWindow
) 
 541     def OnCloseWindow(self
, event
): 
 542         self
.MakeModal(False) 
 546 #---------------------------------------------------------------------- 
 550 class TestSelectionPanel(wx
.Panel
): 
 551     def __init__(self
, parent
, frame
): 
 552         wx
.Panel
.__init
__(self
, parent
, -1) 
 555         self
.list = wx
.ListBox(self
, -1, 
 556                               wx
.DLG_PNT(self
, 10, 10), wx
.DLG_SZE(self
, 100, 100), 
 558         self
.Bind(wx
.EVT_LISTBOX
, self
.OnSelect
, id=self
.list.GetId()) 
 559         self
.Bind(wx
.EVT_LISTBOX_DCLICK
, self
.OnDClick
, id=self
.list.GetId()) 
 561         self
.btn 
= wx
.Button(self
, -1, "Try it!", wx
.DLG_PNT(self
, 120, 10)).SetDefault() 
 562         self
.Bind(wx
.EVT_BUTTON
, self
.OnDClick
) 
 564         self
.text 
= wx
.TextCtrl(self
, -1, "", 
 565                                wx
.DLG_PNT(self
, 10, 115), 
 566                                wx
.DLG_SZE(self
, 200, 50), 
 567                                wx
.TE_MULTILINE | wx
.TE_READONLY
) 
 569         for item 
in theTests
: 
 570             self
.list.Append(item
[0]) 
 573     def OnSelect(self
, event
): 
 574         pos 
= self
.list.GetSelection() 
 575         self
.text
.SetValue(theTests
[pos
][2]) 
 578     def OnDClick(self
, event
): 
 579         pos 
= self
.list.GetSelection() 
 580         title 
= theTests
[pos
][0] 
 581         func 
= theTests
[pos
][1] 
 584             win 
= TestFrame(self
, title
, func
) 
 585             win
.CentreOnParent(wx
.BOTH
) 
 589 #---------------------------------------------------------------------- 
 591 def runTest(frame
, nb
, log
): 
 592     win 
= TestSelectionPanel(nb
, frame
) 
 597 #---------------------------------------------------------------------- 
 599 if __name__ 
== '__main__': 
 601     class MainFrame(wx
.Frame
): 
 603             wx
.Frame
.__init
__(self
, None, -1, "Testing...") 
 605             self
.CreateStatusBar() 
 606             mainmenu 
= wx
.MenuBar() 
 608             menu
.Append(200, 'E&xit', 'Get the heck outta here!') 
 609             mainmenu
.Append(menu
, "&File") 
 610             self
.SetMenuBar(mainmenu
) 
 611             self
.Bind(wx
.EVT_MENU
, self
.OnExit
, id=200) 
 612             self
.panel 
= TestSelectionPanel(self
, self
) 
 613             self
.SetSize((400, 380)) 
 614             self
.Bind(wx
.EVT_CLOSE
, self
.OnCloseWindow
) 
 616         def OnCloseWindow(self
, event
): 
 619         def OnExit(self
, event
): 
 623     class TestApp(wx
.App
): 
 627             self
.SetTopWindow(frame
) 
 634 #----------------------------------------------------------------------