]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/Sizers.py
mention ShouldInheritColours() change
[wxWidgets.git] / wxPython / demo / Sizers.py
CommitLineData
bb0054cd
RD
1#----------------------------------------------------------------------
2# sizer test code
3#----------------------------------------------------------------------
4
2f90df85
RD
5from wxPython.wx import *
6from wxPython.lib.grids import wxGridSizer, wxFlexGridSizer
bb0054cd
RD
7
8#----------------------------------------------------------------------
9
10def makeSimpleBox1(win):
11 box = wxBoxSizer(wxHORIZONTAL)
f0261a72
RD
12 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
13 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
14 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
15 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
bb0054cd
RD
16
17 return box
18
19#----------------------------------------------------------------------
20
21def makeSimpleBox2(win):
22 box = wxBoxSizer(wxVERTICAL)
f0261a72
RD
23 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
24 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
25 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
26 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
bb0054cd
RD
27
28 return box
29
30#----------------------------------------------------------------------
31
32def makeSimpleBox3(win):
33 box = wxBoxSizer(wxHORIZONTAL)
f0261a72
RD
34 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
35 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
36 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
37 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
38 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
bb0054cd
RD
39
40 return box
41
42#----------------------------------------------------------------------
43
44def makeSimpleBox4(win):
45 box = wxBoxSizer(wxHORIZONTAL)
f0261a72
RD
46 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
47 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
48 box.Add(wxButton(win, 1010, "three"), 1, wxEXPAND)
49 box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
50 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
bb0054cd
RD
51
52 return box
53
54#----------------------------------------------------------------------
55
56def makeSimpleBox5(win):
57 box = wxBoxSizer(wxHORIZONTAL)
f0261a72
RD
58 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
59 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
60 box.Add(wxButton(win, 1010, "three"), 3, wxEXPAND)
61 box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
62 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
bb0054cd
RD
63
64 return box
65
66#----------------------------------------------------------------------
67
68def makeSimpleBox6(win):
2f90df85
RD
69 box = wxBoxSizer(wxHORIZONTAL)
70 box.Add(wxButton(win, 1010, "one"), 1, wxALIGN_TOP)
f0261a72 71 box.Add(wxButton(win, 1010, "two"), 1, wxEXPAND)
be2577e4 72 box.Add(wxButton(win, 1010, "three"), 1, wxALIGN_CENTER)
f0261a72 73 box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
2f90df85
RD
74 box.Add(wxButton(win, 1010, "five"), 1, wxALIGN_BOTTOM)
75
76 return box
77
78#----------------------------------------------------------------------
79
80def makeSimpleBox7(win):
81 box = wxBoxSizer(wxHORIZONTAL)
f0261a72
RD
82 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
83 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
84 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
85 box.Add(60, 20, 0, wxEXPAND)
86 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
bb0054cd
RD
87
88 return box
89
9d8bd15f
RD
90#----------------------------------------------------------------------
91
92def makeSimpleBox8(win):
93 box = wxBoxSizer(wxVERTICAL)
94 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
95 box.Add(0,0, 1)
be2577e4 96 box.Add(wxButton(win, 1010, "two"), 0, wxALIGN_CENTER)
9d8bd15f
RD
97 box.Add(0,0, 1)
98 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
99 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
100# box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
101
102 return box
103
bb0054cd 104#----------------------------------------------------------------------
2f90df85 105#----------------------------------------------------------------------
bb0054cd
RD
106
107def makeSimpleBorder1(win):
2f90df85 108 bdr = wxBoxSizer(wxHORIZONTAL)
bb0054cd
RD
109 btn = wxButton(win, 1010, "border")
110 btn.SetSize(wxSize(80, 80))
f0261a72 111 bdr.Add(btn, 1, wxEXPAND|wxALL, 15)
bb0054cd
RD
112
113 return bdr
114
115#----------------------------------------------------------------------
116
117def makeSimpleBorder2(win):
2f90df85 118 bdr = wxBoxSizer(wxHORIZONTAL)
bb0054cd
RD
119 btn = wxButton(win, 1010, "border")
120 btn.SetSize(wxSize(80, 80))
f0261a72 121 bdr.Add(btn, 1, wxEXPAND | wxEAST | wxWEST, 15)
bb0054cd
RD
122
123 return bdr
124
125#----------------------------------------------------------------------
126
127def makeSimpleBorder3(win):
2f90df85 128 bdr = wxBoxSizer(wxHORIZONTAL)
bb0054cd
RD
129 btn = wxButton(win, 1010, "border")
130 btn.SetSize(wxSize(80, 80))
f0261a72 131 bdr.Add(btn, 1, wxEXPAND | wxNORTH | wxWEST, 15)
bb0054cd
RD
132
133 return bdr
134
135#----------------------------------------------------------------------
136#----------------------------------------------------------------------
137
138def makeBoxInBox(win):
139 box = wxBoxSizer(wxVERTICAL)
140
f0261a72 141 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
bb0054cd
RD
142
143 box2 = wxBoxSizer(wxHORIZONTAL)
1fded56b
RD
144 box2.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
145 btn3 = wxButton(win, 1010, "three")
146 box2.Add(btn3, 0, wxEXPAND)
147 box2.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
148 box2.Add(wxButton(win, 1010, "five"), 0, wxEXPAND)
bb0054cd
RD
149
150 box3 = wxBoxSizer(wxVERTICAL)
f0261a72
RD
151 box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxEXPAND),
152 (wxButton(win, 1010, "seven"), 2, wxEXPAND),
153 (wxButton(win, 1010, "eight"), 1, wxEXPAND),
154 (wxButton(win, 1010, "nine"), 1, wxEXPAND),
bb0054cd
RD
155 ])
156
f0261a72
RD
157 box2.Add(box3, 1, wxEXPAND)
158 box.Add(box2, 1, wxEXPAND)
bb0054cd 159
f0261a72 160 box.Add(wxButton(win, 1010, "ten"), 0, wxEXPAND)
bb0054cd 161
1fded56b
RD
162 ##box.Hide(btn3)
163
bb0054cd
RD
164 return box
165
166#----------------------------------------------------------------------
167
168def makeBoxInBorder(win):
2f90df85 169 bdr = wxBoxSizer(wxHORIZONTAL)
bb0054cd 170 box = makeSimpleBox3(win)
f0261a72 171 bdr.Add(box, 1, wxEXPAND | wxALL, 15)
bb0054cd
RD
172
173 return bdr
174
175#----------------------------------------------------------------------
176
177def makeBorderInBox(win):
178 insideBox = wxBoxSizer(wxHORIZONTAL)
5662a243
RD
179
180 box2 = wxBoxSizer(wxHORIZONTAL)
f0261a72
RD
181 box2.AddMany([ (wxButton(win, 1010, "one"), 0, wxEXPAND),
182 (wxButton(win, 1010, "two"), 0, wxEXPAND),
183 (wxButton(win, 1010, "three"), 0, wxEXPAND),
184 (wxButton(win, 1010, "four"), 0, wxEXPAND),
185 (wxButton(win, 1010, "five"), 0, wxEXPAND),
5662a243
RD
186 ])
187
f0261a72 188 insideBox.Add(box2, 0, wxEXPAND)
bb0054cd 189
2f90df85 190 bdr = wxBoxSizer(wxHORIZONTAL)
f0261a72
RD
191 bdr.Add(wxButton(win, 1010, "border"), 1, wxEXPAND | wxALL)
192 insideBox.Add(bdr, 1, wxEXPAND | wxALL, 20)
bb0054cd
RD
193
194 box3 = wxBoxSizer(wxVERTICAL)
f0261a72
RD
195 box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxEXPAND),
196 (wxButton(win, 1010, "seven"), 2, wxEXPAND),
197 (wxButton(win, 1010, "eight"), 1, wxEXPAND),
198 (wxButton(win, 1010, "nine"), 1, wxEXPAND),
5662a243 199 ])
f0261a72 200 insideBox.Add(box3, 1, wxEXPAND)
bb0054cd
RD
201
202 outsideBox = wxBoxSizer(wxVERTICAL)
f0261a72
RD
203 outsideBox.Add(wxButton(win, 1010, "top"), 0, wxEXPAND)
204 outsideBox.Add(insideBox, 1, wxEXPAND)
205 outsideBox.Add(wxButton(win, 1010, "bottom"), 0, wxEXPAND)
bb0054cd
RD
206
207 return outsideBox
208
209
210#----------------------------------------------------------------------
211
2f90df85
RD
212def makeGrid1(win):
213 gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
214
f0261a72
RD
215 gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxEXPAND),
216 (wxButton(win, 1010, 'two'), 0, wxEXPAND),
217 (wxButton(win, 1010, 'three'), 0, wxEXPAND),
218 (wxButton(win, 1010, 'four'), 0, wxEXPAND),
219 (wxButton(win, 1010, 'five'), 0, wxEXPAND),
2f90df85 220 #(75, 50),
f0261a72
RD
221 (wxButton(win, 1010, 'six'), 0, wxEXPAND),
222 (wxButton(win, 1010, 'seven'), 0, wxEXPAND),
223 (wxButton(win, 1010, 'eight'), 0, wxEXPAND),
224 (wxButton(win, 1010, 'nine'), 0, wxEXPAND),
2f90df85
RD
225 ])
226
227 return gs
228
229#----------------------------------------------------------------------
230
231def makeGrid2(win):
232 gs = wxGridSizer(3, 3) # rows, cols, hgap, vgap
233
234 box = wxBoxSizer(wxVERTICAL)
f0261a72
RD
235 box.Add(wxButton(win, 1010, 'A'), 0, wxEXPAND)
236 box.Add(wxButton(win, 1010, 'B'), 1, wxEXPAND)
2f90df85
RD
237
238 gs2 = wxGridSizer(2,2, 4, 4)
f0261a72
RD
239 gs2.AddMany([ (wxButton(win, 1010, 'C'), 0, wxEXPAND),
240 (wxButton(win, 1010, 'E'), 0, wxEXPAND),
241 (wxButton(win, 1010, 'F'), 0, wxEXPAND),
242 (wxButton(win, 1010, 'G'), 0, wxEXPAND)])
2f90df85
RD
243
244 gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxALIGN_RIGHT | wxALIGN_BOTTOM),
f0261a72 245 (wxButton(win, 1010, 'two'), 0, wxEXPAND),
2f90df85 246 (wxButton(win, 1010, 'three'), 0, wxALIGN_LEFT | wxALIGN_BOTTOM),
f0261a72 247 (wxButton(win, 1010, 'four'), 0, wxEXPAND),
be2577e4 248 (wxButton(win, 1010, 'five'), 0, wxALIGN_CENTER),
f0261a72
RD
249 (wxButton(win, 1010, 'six'), 0, wxEXPAND),
250 (box, 0, wxEXPAND | wxALL, 10),
251 (wxButton(win, 1010, 'eight'), 0, wxEXPAND),
252 (gs2, 0, wxEXPAND | wxALL, 4),
2f90df85
RD
253 ])
254
255 return gs
256
257#----------------------------------------------------------------------
258
259def makeGrid3(win):
260 gs = wxFlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
261
f0261a72
RD
262 gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxEXPAND),
263 (wxButton(win, 1010, 'two'), 0, wxEXPAND),
264 (wxButton(win, 1010, 'three'), 0, wxEXPAND),
265 (wxButton(win, 1010, 'four'), 0, wxEXPAND),
266 #(wxButton(win, 1010, 'five'), 0, wxEXPAND),
2f90df85 267 (175, 50),
f0261a72
RD
268 (wxButton(win, 1010, 'six'), 0, wxEXPAND),
269 (wxButton(win, 1010, 'seven'), 0, wxEXPAND),
270 (wxButton(win, 1010, 'eight'), 0, wxEXPAND),
271 (wxButton(win, 1010, 'nine'), 0, wxEXPAND),
2f90df85
RD
272 ])
273
274 gs.AddGrowableRow(0)
275 gs.AddGrowableRow(2)
276 gs.AddGrowableCol(1)
277 return gs
278
279#----------------------------------------------------------------------
280
be2577e4
RD
281def makeGrid4(win):
282 bpos = wxDefaultPosition
283 bsize = wxSize(100, 50)
284 gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
285
286 gs.AddMany([ (wxButton(win, 1010, 'one', bpos, bsize),
287 0, wxALIGN_TOP | wxALIGN_LEFT ),
288 (wxButton(win, 1010, 'two', bpos, bsize),
289 0, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL ),
290 (wxButton(win, 1010, 'three', bpos, bsize),
291 0, wxALIGN_TOP | wxALIGN_RIGHT ),
292 (wxButton(win, 1010, 'four', bpos, bsize),
293 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT ),
294 (wxButton(win, 1010, 'five', bpos, bsize),
295 0, wxALIGN_CENTER ),
296 (wxButton(win, 1010, 'six', bpos, bsize),
297 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ),
298 (wxButton(win, 1010, 'seven', bpos, bsize),
299 0, wxALIGN_BOTTOM | wxALIGN_LEFT ),
300 (wxButton(win, 1010, 'eight', bpos, bsize),
301 0, wxALIGN_BOTTOM | wxALIGN_CENTER_HORIZONTAL ),
302 (wxButton(win, 1010, 'nine', bpos, bsize),
303 0, wxALIGN_BOTTOM | wxALIGN_RIGHT ),
304 ])
305
306 return gs
307
308#----------------------------------------------------------------------
309
310def makeShapes(win):
311 bpos = wxDefaultPosition
312 bsize = wxSize(100, 50)
313 gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
314
315 gs.AddMany([ (wxButton(win, 1010, 'one', bpos, bsize),
316 0, wxSHAPED | wxALIGN_TOP | wxALIGN_LEFT ),
317 (wxButton(win, 1010, 'two', bpos, bsize),
318 0, wxSHAPED | wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL ),
319 (wxButton(win, 1010, 'three', bpos, bsize),
320 0, wxSHAPED | wxALIGN_TOP | wxALIGN_RIGHT ),
321 (wxButton(win, 1010, 'four', bpos, bsize),
322 0, wxSHAPED | wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT ),
323 (wxButton(win, 1010, 'five', bpos, bsize),
324 0, wxSHAPED | wxALIGN_CENTER ),
325 (wxButton(win, 1010, 'six', bpos, bsize),
326 0, wxSHAPED | wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ),
327 (wxButton(win, 1010, 'seven', bpos, bsize),
328 0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_LEFT ),
329 (wxButton(win, 1010, 'eight', bpos, bsize),
330 0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_CENTER_HORIZONTAL ),
331 (wxButton(win, 1010, 'nine', bpos, bsize),
332 0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_RIGHT ),
333 ])
334
335 return gs
336
337#----------------------------------------------------------------------
338
339def makeSimpleBoxShaped(win):
340 box = wxBoxSizer(wxHORIZONTAL)
341 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
342 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
343 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
344 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
345 box.Add(wxButton(win, 1010, "five"), 1, wxSHAPED)
346
347 return box
348
349#----------------------------------------------------------------------
350
bb0054cd
RD
351theTests = [
352 ("Simple horizontal boxes", makeSimpleBox1,
353 "This is a HORIZONTAL box sizer with four non-stretchable buttons held "
354 "within it. Notice that the buttons are added and aligned in the horizontal "
355 "dimension. Also notice that they are fixed size in the horizontal dimension, "
356 "but will stretch vertically."
357 ),
358
359 ("Simple vertical boxes", makeSimpleBox2,
360 "Exactly the same as the previous sample but using a VERTICAL box sizer "
361 "instead of a HORIZONTAL one."
362 ),
363
364 ("Add a stretchable", makeSimpleBox3,
8b9a4190 365 "We've added one more button with the stretchable flag turned on. Notice "
bb0054cd
RD
366 "how it grows to fill the extra space in the otherwise fixed dimension."
367 ),
368
369 ("More than one stretchable", makeSimpleBox4,
370 "Here there are several items that are stretchable, they all divide up the "
371 "extra space evenly."
372 ),
373
374 ("Weighting factor", makeSimpleBox5,
8b9a4190 375 "This one shows more than one stretchable, but one of them has a weighting "
bb0054cd
RD
376 "factor so it gets more of the free space."
377 ),
378
2f90df85
RD
379 ("Edge Affinity", makeSimpleBox6,
380 "For items that don't completly fill their allotted space, and don't "
381 "stretch, you can specify which side (or the center) they should stay "
382 "attached to."
383 ),
384
385 ("Spacer", makeSimpleBox7,
386 "You can add empty space to be managed by a Sizer just as if it were a "
387 "window or another Sizer."
388 ),
389
9d8bd15f
RD
390 ("Centering in available space", makeSimpleBox8,
391 "This one shows an item that does not expand to fill it's space, but rather"
392 "stays centered within it."
393 ),
394
bb0054cd
RD
395# ("Percent Sizer", makeSimpleBox6,
396# "You can use the wxBoxSizer like a Percent Sizer. Just make sure that all "
397# "the weighting factors add up to 100!"
398# ),
399
400 ("", None, ""),
401
402 ("Simple border sizer", makeSimpleBorder1,
be2577e4 403 "The wxBoxSizer can leave empty space around its contents. This one "
bb0054cd
RD
404 "gives a border all the way around."
405 ),
406
407 ("East and West border", makeSimpleBorder2,
408 "You can pick and choose which sides have borders."
409 ),
410
411 ("North and West border", makeSimpleBorder3,
412 "You can pick and choose which sides have borders."
413 ),
414
415 ("", None, ""),
416
417 ("Boxes inside of boxes", makeBoxInBox,
418 "This one shows nesting of boxes within boxes within boxes, using both "
419 "orientations. Notice also that button seven has a greater weighting "
420 "factor than its siblings."
421 ),
422
423 ("Boxes inside a Border", makeBoxInBorder,
8b9a4190 424 "Sizers of different types can be nested within each other as well. "
bb0054cd
RD
425 "Here is a box sizer with several buttons embedded within a border sizer."
426 ),
427
428 ("Border in a Box", makeBorderInBox,
5662a243 429 "Another nesting example. This one has Boxes and a Border inside another Box."
bb0054cd
RD
430 ),
431
2f90df85
RD
432 ("", None, ""),
433
434 ("Simple Grid", makeGrid1,
435 "This is an example of the wxGridSizer. In this case all row heights "
436 "and column widths are kept the same as all the others and all items "
8b9a4190 437 "fill their available space. The horizontal and vertical gaps are set to "
2f90df85
RD
438 "2 pixels each."
439 ),
440
441 ("More Grid Features", makeGrid2,
442 "This is another example of the wxGridSizer. This one has no gaps in the grid, "
443 "but various cells are given different alignment options and some of them "
444 "hold nested sizers."
445 ),
446
447 ("Flexible Grid", makeGrid3,
448 "This grid allows the rows to have different heights and the columns to have "
449 "different widths. You can also specify rows and columns that are growable, "
450 "which we have done for the first and last row and the middle column for "
451 "this example.\n"
452 "\nThere is also a spacer in the middle cell instead of an actual window."
453 ),
454
be2577e4
RD
455 ("Grid with Alignment", makeGrid4,
456 "New alignment flags allow for the positioning of items in any corner or centered "
457 "position."
458 ),
459
460 ("", None, ""),
461
462 ("Proportional resize", makeSimpleBoxShaped,
463 "Managed items can preserve their original aspect ratio. The last item has the "
8b9a4190 464 "wxSHAPED flag set and will resize proportional to its original size."
be2577e4
RD
465 ),
466
467 ("Proportional resize with Alignments", makeShapes,
468 "This one shows various alignments as well as proportional resizing for all items."
469 ),
470
bb0054cd
RD
471 ]
472#----------------------------------------------------------------------
473
474class TestFrame(wxFrame):
475 def __init__(self, parent, title, sizerFunc):
476 wxFrame.__init__(self, parent, -1, title)
477 EVT_BUTTON(self, 1010, self.OnButton)
478
479 self.sizer = sizerFunc(self)
480 self.CreateStatusBar()
a08cbc01 481 self.SetStatusText("Resize this frame to see how the sizers respond...")
2f90df85 482 self.sizer.Fit(self)
bb0054cd 483
1e4a197e 484 self.SetAutoLayout(True)
2f90df85 485 self.SetSizer(self.sizer)
f6bcfd97 486 EVT_CLOSE(self, self.OnCloseWindow)
bb0054cd
RD
487
488 def OnCloseWindow(self, event):
1e4a197e 489 self.MakeModal(False)
bb0054cd
RD
490 self.Destroy()
491
492 def OnButton(self, event):
1e4a197e 493 self.Close(True)
bb0054cd
RD
494
495#----------------------------------------------------------------------
496
497
498
499class TestSelectionPanel(wxPanel):
500 def __init__(self, parent, frame):
501 wxPanel.__init__(self, parent, -1)
502 self.frame = frame
503
504 self.list = wxListBox(self, 401,
2f90df85 505 wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 100),
bb0054cd
RD
506 [])
507 EVT_LISTBOX(self, 401, self.OnSelect)
508 EVT_LISTBOX_DCLICK(self, 401, self.OnDClick)
509
2f90df85 510 self.btn = wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault()
bb0054cd
RD
511 EVT_BUTTON(self, 402, self.OnDClick)
512
513 self.text = wxTextCtrl(self, -1, "",
2f90df85
RD
514 wxDLG_PNT(self, 10, 115),
515 wxDLG_SZE(self, 200, 50),
bb0054cd
RD
516 wxTE_MULTILINE | wxTE_READONLY)
517
518 for item in theTests:
519 self.list.Append(item[0])
520
521
522
523 def OnSelect(self, event):
524 pos = self.list.GetSelection()
525 self.text.SetValue(theTests[pos][2])
526
527
528 def OnDClick(self, event):
529 pos = self.list.GetSelection()
530 title = theTests[pos][0]
531 func = theTests[pos][1]
532
533 if func:
534 win = TestFrame(self, title, func)
535 win.CentreOnParent(wxBOTH)
1e4a197e
RD
536 win.Show(True)
537 win.MakeModal(True)
bb0054cd
RD
538
539#----------------------------------------------------------------------
540
541def runTest(frame, nb, log):
542 win = TestSelectionPanel(nb, frame)
543 return win
544
2f90df85
RD
545overview = ""
546#wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
547#wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
548#wxBorderSizer.__doc__
bb0054cd
RD
549
550#----------------------------------------------------------------------
551
552
553
554if __name__ == '__main__':
555
556 class MainFrame(wxFrame):
557 def __init__(self):
493f1553 558 wxFrame.__init__(self, None, -1, "Testing...")
bb0054cd 559
1e4a197e
RD
560 self.CreateStatusBar()
561 mainmenu = wxMenuBar()
562 menu = wxMenu()
563 menu.Append(200, 'E&xit', 'Get the heck outta here!')
564 mainmenu.Append(menu, "&File")
565 self.SetMenuBar(mainmenu)
bb0054cd 566 EVT_MENU(self, 200, self.OnExit)
2f90df85 567 self.panel = TestSelectionPanel(self, self)
bb0054cd 568 self.SetSize(wxSize(400, 380))
f6bcfd97 569 EVT_CLOSE(self, self.OnCloseWindow)
bb0054cd
RD
570
571 def OnCloseWindow(self, event):
572 self.Destroy()
573
574 def OnExit(self, event):
1e4a197e 575 self.Close(True)
bb0054cd
RD
576
577
578 class TestApp(wxApp):
579 def OnInit(self):
580 frame = MainFrame()
1e4a197e 581 frame.Show(True)
bb0054cd 582 self.SetTopWindow(frame)
1e4a197e 583 return True
bb0054cd
RD
584
585 app = TestApp(0)
586 app.MainLoop()
587
588
589#----------------------------------------------------------------------