]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Sizers.py
fixed compile error
[wxWidgets.git] / wxPython / demo / Sizers.py
1 # 11/26/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
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
7 # hackish looking.
8 #
9
10 #----------------------------------------------------------------------
11 # sizer test code
12 #----------------------------------------------------------------------
13
14 import wx
15
16 #----------------------------------------------------------------------
17
18 class SampleWindow(wx.PyWindow):
19 """
20 A simple window that is used as sizer items in the tests below to
21 show how the various sizers work.
22 """
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
28 )
29 self.text = text
30 if size != wx.DefaultSize:
31 self.bestsize = size
32 else:
33 self.bestsize = (80,25)
34 self.SetSize(self.GetBestSize())
35
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)
39
40
41 def OnPaint(self, evt):
42 sz = self.GetSize()
43 dc = wx.PaintDC(self)
44 w,h = dc.GetTextExtent(self.text)
45 dc.Clear()
46 dc.DrawText(self.text, (sz.width-w)/2, (sz.height-h)/2)
47
48 def OnSize(self, evt):
49 self.Refresh()
50
51 def OnCloseParent(self, evt):
52 p = wx.GetTopLevelParent(self)
53 if p:
54 p.Close()
55
56 def DoGetBestSize(self):
57 return self.bestsize
58
59
60 #----------------------------------------------------------------------
61
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)
68
69 return box
70
71 #----------------------------------------------------------------------
72
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)
79
80 return box
81
82 #----------------------------------------------------------------------
83
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)
91
92 return box
93
94 #----------------------------------------------------------------------
95
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)
103
104 return box
105
106 #----------------------------------------------------------------------
107
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)
115
116 return box
117
118 #----------------------------------------------------------------------
119
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)
127
128 return box
129
130 #----------------------------------------------------------------------
131
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)
139
140 return box
141
142 #----------------------------------------------------------------------
143
144 def makeSimpleBox8(win):
145 box = wx.BoxSizer(wx.VERTICAL)
146 box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
147 box.Add((0,0), 1)
148 box.Add(SampleWindow(win, "two"), 0, wx.ALIGN_CENTER)
149 box.Add((0,0), 1)
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)
153
154 return box
155
156 #----------------------------------------------------------------------
157 #----------------------------------------------------------------------
158
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)
164
165 return bdr
166
167 #----------------------------------------------------------------------
168
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)
174
175 return bdr
176
177 #----------------------------------------------------------------------
178
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)
184
185 return bdr
186
187 #----------------------------------------------------------------------
188 #----------------------------------------------------------------------
189
190 def makeBoxInBox(win):
191 box = wx.BoxSizer(wx.VERTICAL)
192
193 box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
194
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)
201
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),
207 ])
208
209 box2.Add(box3, 1, wx.EXPAND)
210 box.Add(box2, 1, wx.EXPAND)
211
212 box.Add(SampleWindow(win, "ten"), 0, wx.EXPAND)
213
214 ##box.Hide(btn3)
215
216 return box
217
218 #----------------------------------------------------------------------
219
220 def makeBoxInBorder(win):
221 bdr = wx.BoxSizer(wx.HORIZONTAL)
222 box = makeSimpleBox3(win)
223 bdr.Add(box, 1, wx.EXPAND | wx.ALL, 15)
224
225 return bdr
226
227 #----------------------------------------------------------------------
228
229 def makeBorderInBox(win):
230 insideBox = wx.BoxSizer(wx.HORIZONTAL)
231
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),
238 ])
239
240 insideBox.Add(box2, 0, wx.EXPAND)
241
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)
245
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),
251 ])
252 insideBox.Add(box3, 1, wx.EXPAND)
253
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)
258
259 return outsideBox
260
261
262 #----------------------------------------------------------------------
263
264 def makeGrid1(win):
265 gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
266
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),
272 #(75, 50),
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),
277 ])
278
279 return gs
280
281 #----------------------------------------------------------------------
282
283 def makeGrid2(win):
284 gs = wx.GridSizer(3, 3) # rows, cols, hgap, vgap
285
286 box = wx.BoxSizer(wx.VERTICAL)
287 box.Add(SampleWindow(win, 'A'), 0, wx.EXPAND)
288 box.Add(SampleWindow(win, 'B'), 1, wx.EXPAND)
289
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)])
295
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),
305 ])
306
307 return gs
308
309 #----------------------------------------------------------------------
310
311 def makeGrid3(win):
312 gs = wx.FlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
313
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),
319 ((175, 50)),
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),
324 ])
325
326 gs.AddGrowableRow(0)
327 gs.AddGrowableRow(2)
328 gs.AddGrowableCol(1)
329 return gs
330
331 #----------------------------------------------------------------------
332
333 def makeGrid4(win):
334 bpos = wx.DefaultPosition
335 bsize = wx.Size(100, 50)
336 gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
337
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 ),
356 ])
357
358 return gs
359
360 #----------------------------------------------------------------------
361
362 def makeShapes(win):
363 bpos = wx.DefaultPosition
364 bsize = wx.Size(100, 50)
365 gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
366
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 ),
385 ])
386
387 return gs
388
389 #----------------------------------------------------------------------
390
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)
398
399 return box
400
401 #----------------------------------------------------------------------
402
403 theTests = [
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."
409 ),
410
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."
414 ),
415
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."
419 ),
420
421 ("More than one stretchable", makeSimpleBox4,
422 "Here there are several items that are stretchable, they all divide up the "
423 "extra space evenly."
424 ),
425
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."
429 ),
430
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 "
434 "attached to."
435 ),
436
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."
440 ),
441
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."
445 ),
446
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!"
450 # ),
451
452 ("", None, ""),
453
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."
457 ),
458
459 ("East and West border", makeSimpleBorder2,
460 "You can pick and choose which sides have borders."
461 ),
462
463 ("North and West border", makeSimpleBorder3,
464 "You can pick and choose which sides have borders."
465 ),
466
467 ("", None, ""),
468
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."
473 ),
474
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."
478 ),
479
480 ("Border in a Box", makeBorderInBox,
481 "Another nesting example. This one has Boxes and a Border inside another Box."
482 ),
483
484 ("", None, ""),
485
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 "
490 "2 pixels each."
491 ),
492
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."
497 ),
498
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 "
503 "this example.\n"
504 "\nThere is also a spacer in the middle cell instead of an actual window."
505 ),
506
507 ("Grid with Alignment", makeGrid4,
508 "New alignment flags allow for the positioning of items in any corner or centered "
509 "position."
510 ),
511
512 ("", None, ""),
513
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."
517 ),
518
519 ("Proportional resize with Alignments", makeShapes,
520 "This one shows various alignments as well as proportional resizing for all items."
521 ),
522
523 ]
524 #----------------------------------------------------------------------
525
526 class TestFrame(wx.Frame):
527 def __init__(self, parent, title, sizerFunc):
528 wx.Frame.__init__(self, parent, -1, title)
529
530 p = wx.Panel(self, -1)
531
532 self.sizer = sizerFunc(p)
533 self.CreateStatusBar()
534 self.SetStatusText("Resize this frame to see how the sizers respond...")
535 self.sizer.Fit(p)
536
537 p.SetSizer(self.sizer)
538 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
539 self.Fit()
540
541 def OnCloseWindow(self, event):
542 self.MakeModal(False)
543 self.Destroy()
544
545
546 #----------------------------------------------------------------------
547
548
549
550 class TestSelectionPanel(wx.Panel):
551 def __init__(self, parent, frame):
552 wx.Panel.__init__(self, parent, -1)
553 self.frame = frame
554
555 self.list = wx.ListBox(self, -1,
556 wx.DLG_PNT(self, 10, 10), wx.DLG_SZE(self, 100, 100),
557 [])
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())
560
561 self.btn = wx.Button(self, -1, "Try it!", wx.DLG_PNT(self, 120, 10)).SetDefault()
562 self.Bind(wx.EVT_BUTTON, self.OnDClick)
563
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)
568
569 for item in theTests:
570 self.list.Append(item[0])
571
572
573 def OnSelect(self, event):
574 pos = self.list.GetSelection()
575 self.text.SetValue(theTests[pos][2])
576
577
578 def OnDClick(self, event):
579 pos = self.list.GetSelection()
580 title = theTests[pos][0]
581 func = theTests[pos][1]
582
583 if func:
584 win = TestFrame(self, title, func)
585 win.CentreOnParent(wx.BOTH)
586 win.Show(True)
587 win.MakeModal(True)
588
589 #----------------------------------------------------------------------
590
591 def runTest(frame, nb, log):
592 win = TestSelectionPanel(nb, frame)
593 return win
594
595 overview = ""
596
597 #----------------------------------------------------------------------
598
599 if __name__ == '__main__':
600
601 class MainFrame(wx.Frame):
602 def __init__(self):
603 wx.Frame.__init__(self, None, -1, "Testing...")
604
605 self.CreateStatusBar()
606 mainmenu = wx.MenuBar()
607 menu = wx.Menu()
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)
615
616 def OnCloseWindow(self, event):
617 self.Destroy()
618
619 def OnExit(self, event):
620 self.Close(True)
621
622
623 class TestApp(wx.App):
624 def OnInit(self):
625 frame = MainFrame()
626 frame.Show(True)
627 self.SetTopWindow(frame)
628 return True
629
630 app = TestApp(False)
631 app.MainLoop()
632
633
634 #----------------------------------------------------------------------