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