]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/tests/test4.py
Commented out constructor causing ambiguity
[wxWidgets.git] / utils / wxPython / tests / test4.py
CommitLineData
7bf85405
RD
1#!/bin/env python
2#----------------------------------------------------------------------------
3# Name: test4.py
4# Purpose: Testing lots of stuff, controls, window types, etc.
5#
6# Author: Robin Dunn
7#
8# Created:
9# RCS-ID: $Id$
10# Copyright: (c) 1998 by Total Control Software
11# Licence: wxWindows license
12#----------------------------------------------------------------------------
13
14
15from wxPython import *
16
9c039d08 17import time
7bf85405
RD
18
19#---------------------------------------------------------------------------
20
21class TestSimpleControlsDlg(wxDialog):
22 def __init__(self, parent, log):
23 self.log = log
24 wxDialog.__init__(self, parent, -1, "Test Simple Controls",
25 wxPyDefaultPosition, wxSize(350, 350))
26
27
28 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
29 'six', 'seven', 'eight']
30
31 y_pos = 5
32 delta = 25
33
34 wxStaticText(self, -1, "wxTextCtrl", wxPoint(5, y_pos), wxSize(75, 20))
35 wxTextCtrl(self, 10, "", wxPoint(80, y_pos), wxSize(150, 20))
36 EVT_TEXT(self, 10, self.EvtText)
37 y_pos = y_pos + delta
38
39 wxCheckBox(self, 20, "wxCheckBox", wxPoint(80, y_pos), wxSize(150, 20))
40 EVT_CHECKBOX(self, 20, self.EvtCheckBox)
41 y_pos = y_pos + delta
42
43 rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(80, y_pos), wxPyDefaultSize,
44 sampleList, 3, wxRA_HORIZONTAL)
45 EVT_RADIOBOX(self, 30, self.EvtRadioBox)
46 width, height = rb.GetSize()
47 y_pos = y_pos + height + 5
48
49 wxStaticText(self, -1, "wxChoice", wxPoint(5, y_pos), wxSize(75, 20))
50 wxChoice(self, 40, wxPoint(80, y_pos), wxSize(95, 20), #wxPyDefaultSize,
51 sampleList)
52 EVT_CHOICE(self, 40, self.EvtChoice)
53 y_pos = y_pos + delta
54
55 wxStaticText(self, -1, "wxComboBox", wxPoint(5, y_pos), wxSize(75, 18))
56 wxComboBox(self, 50, "default value", wxPoint(80, y_pos), wxSize(95, 20),
57 sampleList, wxCB_DROPDOWN)
58 EVT_COMBOBOX(self, 50, self.EvtComboBox)
59 y_pos = y_pos + delta
60
61 wxStaticText(self, -1, "wxListBox", wxPoint(5, y_pos), wxSize(75, 18))
62 lb = wxListBox(self, 60, wxPoint(80, y_pos), wxPyDefaultSize,
63 sampleList, wxLB_SINGLE)
64 EVT_LISTBOX(self, 60, self.EvtListBox)
65 EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
66 lb.SetSelection(0)
67 width, height = lb.GetSize()
68 y_pos = y_pos + height + 5
69
70
71
72 y_pos = y_pos + 15
73 wxButton(self, wxID_OK, ' OK ', wxPoint(80, y_pos), wxPyDefaultSize).SetDefault()
74 wxButton(self, wxID_CANCEL, ' Cancel ', wxPoint(140, y_pos))
75
76
77 def EvtText(self, event):
78 self.log.WriteText('EvtText: %s\n' % event.GetString())
79
80 def EvtCheckBox(self, event):
81 self.log.WriteText('EvtCheckBox: %d\n' % event.GetInt())
82
83 def EvtRadioBox(self, event):
84 self.log.WriteText('EvtRadioBox: %d\n' % event.GetInt())
85
86 def EvtChoice(self, event):
87 self.log.WriteText('EvtChoice: %s\n' % event.GetString())
88
89 def EvtComboBox(self, event):
90 self.log.WriteText('EvtComboBox: %s\n' % event.GetString())
91
92 def EvtListBox(self, event):
93 self.log.WriteText('EvtListBox: %s\n' % event.GetString())
94
95 def EvtListBoxDClick(self, event):
96 self.log.WriteText('EvtListBoxDClick:\n')
97
98
99
100#---------------------------------------------------------------------------
101
102class TestTimer(wxTimer):
103 def __init__(self, log):
104 wxTimer.__init__(self)
105 self.log = log
106
107 def Notify(self):
108 wxBell()
109 self.log.WriteText('beep!\n')
110
111
112#---------------------------------------------------------------------------
113
114class TestLayoutConstraints(wxFrame):
115 def __init__(self, parent):
116 wxFrame.__init__(self, parent, -1, 'Test Layout Constraints',
117 wxPyDefaultPosition, wxSize(500, 300))
118
119 self.SetAutoLayout(true)
120 EVT_BUTTON(self, 100, self.OnButton)
121
122 self.panelA = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
123 wxSIMPLE_BORDER)
124 self.panelA.SetBackgroundColour(wxBLUE)
125 lc = wxLayoutConstraints()
126 lc.top.SameAs(self, wxTop, 10)
127 lc.left.SameAs(self, wxLeft, 10)
128 lc.bottom.SameAs(self, wxBottom, 10)
129 lc.right.PercentOf(self, wxRight, 50)
130 self.panelA.SetConstraints(lc)
131
132 self.panelB = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
133 wxSIMPLE_BORDER)
134 self.panelB.SetBackgroundColour(wxRED)
135 lc = wxLayoutConstraints()
136 lc.top.SameAs(self, wxTop, 10)
137 lc.right.SameAs(self, wxRight, 10)
138 lc.bottom.PercentOf(self, wxBottom, 30)
139 lc.left.RightOf(self.panelA, 10)
140 self.panelB.SetConstraints(lc)
141
142 self.panelC = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
143 wxSIMPLE_BORDER)
144 self.panelC.SetBackgroundColour(wxWHITE)
145 lc = wxLayoutConstraints()
146 lc.top.Below(self.panelB, 10)
147 lc.right.SameAs(self, wxRight, 10)
148 lc.bottom.SameAs(self, wxBottom, 10)
149 lc.left.RightOf(self.panelA, 10)
150 self.panelC.SetConstraints(lc)
151
152 b = wxButton(self.panelA, 100, ' Panel A ')
153 lc = wxLayoutConstraints()
154 lc.centreX.SameAs (self.panelA, wxCentreX)
155 lc.centreY.SameAs (self.panelA, wxCentreY)
156 lc.height.AsIs ()
157 lc.width.PercentOf (self.panelA, wxWidth, 50)
158 b.SetConstraints(lc);
159
160 b = wxButton(self.panelB, 100, ' Panel B ')
161 lc = wxLayoutConstraints()
162 lc.top.SameAs (self.panelB, wxTop, 2)
163 lc.right.SameAs (self.panelB, wxRight, 4)
164 lc.height.AsIs ()
165 lc.width.AsIs ()
166 b.SetConstraints(lc);
167
168 self.panelD = wxWindow(self.panelC, -1, wxPyDefaultPosition, wxPyDefaultSize,
169 wxSIMPLE_BORDER)
170 self.panelD.SetBackgroundColour(wxGREEN)
171 wxStaticText(self.panelD, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN)
172
173 b = wxButton(self.panelC, 100, ' Panel C ')
174 lc = wxLayoutConstraints()
175 lc.top.Below (self.panelD)
176 lc.left.RightOf (self.panelD)
177 lc.height.AsIs ()
178 lc.width.AsIs ()
179 b.SetConstraints(lc);
180
181 lc = wxLayoutConstraints()
182 lc.bottom.PercentOf (self.panelC, wxHeight, 50)
183 lc.right.PercentOf (self.panelC, wxWidth, 50)
184 lc.height.SameAs (b, wxHeight)
185 lc.width.SameAs (b, wxWidth)
186 self.panelD.SetConstraints(lc);
187
188
189 def OnButton(self, event):
190 self.Close(true)
191
192
193 def OnCloseWindow(self, event):
194 self.Destroy()
195
196
197#---------------------------------------------------------------------------
198
199class TestGrid(wxFrame):
200 def __init__(self, parent):
201 wxFrame.__init__(self, parent, -1, 'Test Grid',
202 wxPyDefaultPosition, wxSize(500, 300))
203
204 grid = wxGrid(self, -1)
205
206 grid.CreateGrid(16, 16)
207 grid.SetColumnWidth(3, 200)
208 grid.SetRowHeight(4, 45)
209 grid.SetCellValue("First cell", 0, 0)
210 grid.SetCellValue("Another cell", 1, 1)
211 grid.SetCellValue("Yet another cell", 2, 2)
212 grid.SetCellTextFont(wxFont(12, wxROMAN, wxITALIC, wxNORMAL), 0, 0)
213 grid.SetCellTextColour(wxRED, 1, 1)
214 grid.SetCellBackgroundColour(wxCYAN, 2, 2)
215 grid.UpdateDimensions()
216 grid.AdjustScrollbars()
217
218
219 def OnCloseWindow(self, event):
220 self.Destroy()
221
222
223#---------------------------------------------------------------------------
224
9c039d08
RD
225
226class ColoredPanel(wxWindow):
227 def __init__(self, parent, color):
228 wxWindow.__init__(self, parent, -1,
229 wxPyDefaultPosition, wxPyDefaultSize, wxRAISED_BORDER)
230 self.SetBackgroundColour(color)
231
232
7bf85405
RD
233class TestNotebookWindow(wxFrame):
234 def __init__(self, parent):
235 wxFrame.__init__(self, parent, -1, 'Test wxNotebook',
236 wxPyDefaultPosition, wxPyDefaultSize)
237
238 nb = wxNotebook(self, -1)
239
9c039d08 240 win = ColoredPanel(nb, wxBLUE)
7bf85405 241 nb.AddPage(win, "Blue")
9c039d08
RD
242 st = wxStaticText(win, -1, "You can put any type of window here!", wxPoint(10, 10))
243 st.SetForegroundColour(wxWHITE)
244 st.SetBackgroundColour(wxBLUE)
7bf85405 245
9c039d08 246 win = ColoredPanel(nb, wxRED)
7bf85405
RD
247 nb.AddPage(win, "Red")
248
9c039d08 249 win = ColoredPanel(nb, wxGREEN)
7bf85405
RD
250 nb.AddPage(win, "Green")
251
9c039d08 252 win = ColoredPanel(nb, wxCYAN)
7bf85405
RD
253 nb.AddPage(win, "Cyan")
254
9c039d08 255 win = ColoredPanel(nb, wxWHITE)
7bf85405
RD
256 nb.AddPage(win, "White")
257
9c039d08 258 win = ColoredPanel(nb, wxBLACK)
7bf85405
RD
259 nb.AddPage(win, "Black")
260
9c039d08 261 win = ColoredPanel(nb, wxNamedColour('MIDNIGHT BLUE'))
7bf85405
RD
262 nb.AddPage(win, "MIDNIGHT BLUE")
263
9c039d08 264 win = ColoredPanel(nb, wxNamedColour('INDIAN RED'))
7bf85405
RD
265 nb.AddPage(win, "INDIAN RED")
266
267
268 nb.SetSelection(0)
9c039d08
RD
269 self.SetSize(wxSize(300, 300)) # force a redraw so the notebook will draw
270
271
272 def OnCloseWindow(self, event):
273 self.Destroy()
274
275#---------------------------------------------------------------------------
276
277class TestSplitterWindow(wxFrame):
278 def __init__(self, parent):
279 wxFrame.__init__(self, parent, -1, 'Test wxSplitterWindow',
280 wxPyDefaultPosition, wxSize(500, 300))
281
282 splitter = wxSplitterWindow(self, -1)
283
284 p1 = ColoredPanel(splitter, wxRED)
285 wxStaticText(p1, -1, "Panel One", wxPoint(5,5)).SetBackgroundColour(wxRED)
286
287 p2 = ColoredPanel(splitter, wxBLUE)
288 wxStaticText(p2, -1, "Panel Two", wxPoint(5,5)).SetBackgroundColour(wxBLUE)
289
290 splitter.SplitVertically(p1, p2)
291
292
293 def OnCloseWindow(self, event):
294 self.Destroy()
295
296
297#---------------------------------------------------------------------------
298
299class CustomStatusBar(wxStatusBar):
300 def __init__(self, parent):
301 wxStatusBar.__init__(self, parent, -1)
302 self.SetFieldsCount(3)
303
304 self.SetStatusText("A Custom StatusBar...", 0)
305
306 self.cb = wxCheckBox(self, 1001, "toggle clock")
307 EVT_CHECKBOX(self, 1001, self.OnToggleClock)
308 self.cb.SetValue(true)
309
310 # figure out how tall to make it.
311 dc = wxClientDC(self)
312 dc.SetFont(self.GetFont())
313 (w,h, d,e) = dc.GetTextExtent('X')
314 h = int(h * 1.8)
315 self.SetSize(wxSize(100, h))
316
317 # start our timer
318 self.timer = wxPyTimer(self.Notify)
319 self.timer.Start(1000)
320 self.Notify()
321
322
323 # Time-out handler
324 def Notify(self):
325 t = time.localtime(time.time())
326 st = time.strftime("%d-%b-%Y %I:%M:%S", t)
327 self.SetStatusText(st, 2)
328
329 # the checkbox was clicked
330 def OnToggleClock(self, event):
331 if self.cb.GetValue():
332 self.timer.Start(1000)
333 self.Notify()
334 else:
335 self.timer.Stop()
336
337 # reposition the checkbox
338 def OnSize(self, event):
339 rect = self.GetFieldRect(1)
340 self.cb.SetPosition(wxPoint(rect.x+2, rect.y+2))
341 self.cb.SetSize(wxSize(rect.width-4, rect.height-4))
342
343
344
345class TestCustomStatusBar(wxFrame):
346 def __init__(self, parent):
347 wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar',
348 wxPyDefaultPosition, wxSize(500, 300))
349 wxWindow(self, -1)
7bf85405 350
9c039d08
RD
351 self.sb = CustomStatusBar(self)
352 self.SetStatusBar(self.sb)
7bf85405
RD
353
354 def OnCloseWindow(self, event):
9c039d08 355 self.sb.timer.Stop()
7bf85405
RD
356 self.Destroy()
357
9c039d08
RD
358
359#---------------------------------------------------------------------------
360
361class TestToolBar(wxFrame):
362 def __init__(self, parent, log):
363 wxFrame.__init__(self, parent, -1, 'Test ToolBar',
364 wxPyDefaultPosition, wxSize(500, 300))
365 self.log = log
366
367 wxWindow(self, -1)
368
369 tb = self.CreateToolBar()
370 #tb = wxToolBar(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
371 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
372 #self.SetToolBar(tb)
373
374 tb.AddTool(10, wxNoRefBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
375 NULL, false, -1, -1, "New")
376 EVT_TOOL(self, 10, self.OnToolClick)
377 EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
378
379 tb.AddTool(20, wxNoRefBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
380 NULL, false, -1, -1, "Open")
381 EVT_TOOL(self, 20, self.OnToolClick)
382 EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
383
384 tb.AddSeparator()
385 tb.AddTool(30, wxNoRefBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
386 NULL, false, -1, -1, "Copy")
387 EVT_TOOL(self, 30, self.OnToolClick)
388 EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
389
390 tb.AddTool(40, wxNoRefBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
391 NULL, false, -1, -1, "Paste")
392 EVT_TOOL(self, 40, self.OnToolClick)
393 EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
394
395 tb.AddSeparator()
396
397 tb.AddTool(50, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
398 NULL, true, -1, -1, "Toggle this")
399 EVT_TOOL(self, 50, self.OnToolClick)
400 EVT_TOOL_RCLICKED(self, 50, self.OnToolRClick)
401
402 tb.AddTool(60, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
403 wxNoRefBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
404 true, -1, -1, "Toggle with 2 bitmaps")
405 EVT_TOOL(self, 60, self.OnToolClick)
406 EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
407
408 tb.Realize()
409
410
411 def OnCloseWindow(self, event):
412 self.Destroy()
413
414 def OnToolClick(self, event):
415 self.log.WriteText("tool %s clicked\n" % event.GetId())
416
417 def OnToolRClick(self, event):
418 self.log.WriteText("tool %s right-clicked\n" % event.GetId())
419
420
421#---------------------------------------------------------------------------
422#---------------------------------------------------------------------------
7bf85405
RD
423#---------------------------------------------------------------------------
424
425class AppFrame(wxFrame):
426 def __init__(self, parent, id, title):
427 wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
428 wxSize(420, 200))
f57d7932
RD
429 if wxPlatform == '__WXMSW__':
430 self.icon = wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO)
431 self.SetIcon(self.icon)
7bf85405
RD
432
433 self.mainmenu = wxMenuBar()
434 menu = wxMenu()
435 menu.Append(200, 'E&xit', 'Get the heck outta here!')
436 EVT_MENU(self, 200, self.OnFileExit)
437 self.mainmenu.Append(menu, '&File')
438
439 menu = self.MakeTestsMenu()
440 self.mainmenu.Append(menu, '&Tests')
441 self.SetMenuBar(self.mainmenu)
442
443 self.log = wxTextCtrl(self, -1, '', wxPyDefaultPosition, wxPyDefaultSize,
444 wxTE_MULTILINE|wxTE_READONLY)
445 self.log.WriteText('Test 4:\n')
446 (w, self.charHeight) = self.log.GetTextExtent('X')
447
448
449 def MakeTestsMenu(self):
450 menu = wxMenu()
451
452 mID = NewId()
453 menu.Append(mID, '&Simple Controls')
454 EVT_MENU(self, mID, self.OnTestSimpleControls)
455
456 mID = NewId()
457 menu.Append(mID, '&Timer', '', true)
458 EVT_MENU(self, mID, self.OnTestTimer)
459 self.timerID = mID
460 self.timer = None
461
462 mID = NewId()
463 menu.Append(mID, '&Layout Constraints')
464 EVT_MENU(self, mID, self.OnTestLayoutConstraints)
465
466 mID = NewId()
467 menu.Append(mID, '&Grid')
468 EVT_MENU(self, mID, self.OnTestGrid)
469
470
471 smenu = wxMenu() # make a sub-menu
472
473 mID = NewId()
474 smenu.Append(mID, '&Colour')
475 EVT_MENU(self, mID, self.OnTestColourDlg)
476
477 mID = NewId()
478 smenu.Append(mID, '&Directory')
479 EVT_MENU(self, mID, self.OnTestDirDlg)
480
481 mID = NewId()
482 smenu.Append(mID, '&File')
483 EVT_MENU(self, mID, self.OnTestFileDlg)
484
485 mID = NewId()
486 smenu.Append(mID, '&Single Choice')
487 EVT_MENU(self, mID, self.OnTestSingleChoiceDlg)
488
489 mID = NewId()
490 smenu.Append(mID, '&TextEntry')
491 EVT_MENU(self, mID, self.OnTestTextEntryDlg)
492
493 mID = NewId()
494 smenu.Append(mID, '&Font')
495 EVT_MENU(self, mID, self.OnTestFontDlg)
496
497 mID = NewId()
498 smenu.Append(mID, '&PageSetup')
499 EVT_MENU(self, mID, self.OnTestPageSetupDlg)
500
501 mID = NewId()
502 smenu.Append(mID, '&Print')
503 EVT_MENU(self, mID, self.OnTestPrintDlg)
504
505 mID = NewId()
506 smenu.Append(mID, '&Message')
507 EVT_MENU(self, mID, self.OnTestMessageDlg)
508
509
510 menu.AppendMenu(NewId(), '&Common Dialogs', smenu)
511
512
513 mID = NewId()
514 menu.Append(mID, '&Notebook')
515 EVT_MENU(self, mID, self.OnTestNotebook)
516
9c039d08
RD
517 mID = NewId()
518 menu.Append(mID, '&Splitter Window')
519 EVT_MENU(self, mID, self.OnTestSplitter)
520
521 mID = NewId()
522 menu.Append(mID, '&Custom StatusBar')
523 EVT_MENU(self, mID, self.OnTestCustomStatusBar)
524
525 mID = NewId()
526 menu.Append(mID, '&ToolBar')
527 EVT_MENU(self, mID, self.OnTestToolBar)
528
7bf85405
RD
529 return menu
530
531
532
533
534 def WriteText(self, str):
535 self.log.WriteText(str)
21f4bf45
RD
536 if wxPlatform == '__WXMSW__':
537 w, h = self.log.GetClientSize()
538 numLines = h/self.charHeight
539 x, y = self.log.PositionToXY(self.log.GetLastPosition())
540 self.log.ShowPosition(self.log.XYToPosition(x, y-numLines+1))
7bf85405
RD
541
542 def OnFileExit(self, event):
543 self.Close()
544
545 def OnCloseWindow(self, event):
546 self.Destroy()
547
548
549
550
551 def OnTestSimpleControls(self, event):
552 dlg = TestSimpleControlsDlg(self, self)
7bf85405 553 dlg.Centre()
f57d7932 554 dlg.ShowModal()
7bf85405
RD
555 dlg.Destroy()
556
557 def OnTestTimer(self, event):
558 if self.timer:
559 self.mainmenu.Check(self.timerID, false)
560 self.timer.Stop()
561 self.timer = None
562 else:
563 self.mainmenu.Check(self.timerID, true)
564 self.timer = TestTimer(self)
565 self.timer.Start(1000)
566
567 def OnTestLayoutConstraints(self, event):
568 win = TestLayoutConstraints(self)
569 win.Show(true)
570
571 def OnTestGrid(self, event):
572 win = TestGrid(self)
573 win.Show(true)
574 win.SetSize(wxSize(505, 300)) # have to force a resize, or the grid doesn't
575 # show up for some reason....
576
577 def OnTestColourDlg(self, event):
578 data = wxColourData()
579 data.SetChooseFull(true)
580 dlg = wxColourDialog(self, data)
581 if dlg.ShowModal() == wxID_OK:
582 data = dlg.GetColourData()
583 self.log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
584 dlg.Destroy()
585
586 def OnTestDirDlg(self, event):
587 dlg = wxDirDialog(self)
588 if dlg.ShowModal() == wxID_OK:
589 self.log.WriteText('You selected: %s\n' % dlg.GetPath())
590 dlg.Destroy()
591
592 def OnTestFileDlg(self, event):
593 dlg = wxFileDialog(self, "Choose a file", ".", "", "*.*", wxOPEN)
594 if dlg.ShowModal() == wxID_OK:
595 self.log.WriteText('You selected: %s\n' % dlg.GetPath())
596 dlg.Destroy()
597
598 def OnTestSingleChoiceDlg(self, event):
599 dlg = wxSingleChoiceDialog(self, 'Test Single Choice', 'The Caption',
600 ['zero', 'one', 'two', 'three', 'four', 'five',
601 'six', 'seven', 'eight'])
602 if dlg.ShowModal() == wxID_OK:
603 self.log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
604 dlg.Destroy()
605
606 def OnTestTextEntryDlg(self, event):
607 dlg = wxTextEntryDialog(self, 'What is your favorite programming language?',
608 'Duh??', 'Python')
609 #dlg.SetValue("Python is the best!") #### this doesn't work?
610 if dlg.ShowModal() == wxID_OK:
611 self.log.WriteText('You entered: %s\n' % dlg.GetValue())
612 dlg.Destroy()
613
614
615 def OnTestFontDlg(self, event):
616 dlg = wxFontDialog(self)
617 if dlg.ShowModal() == wxID_OK:
618 data = dlg.GetFontData()
619 font = data.GetChosenFont()
620 self.log.WriteText('You selected: "%s", %d points, color %s\n' %
621 (font.GetFaceName(), font.GetPointSize(),
622 data.GetColour().Get()))
623 dlg.Destroy()
624
625
626 def OnTestPageSetupDlg(self, event):
627 data = wxPageSetupData()
628 data.SetMarginTopLeft(wxPoint(50,50))
629 data.SetMarginBottomRight(wxPoint(50,50))
630 dlg = wxPageSetupDialog(self, data)
631 if dlg.ShowModal() == wxID_OK:
632 data = dlg.GetPageSetupData()
633 tl = data.GetMarginTopLeft()
634 br = data.GetMarginBottomRight()
635 self.log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
636 dlg.Destroy()
637
638 def OnTestPrintDlg(self, event):
639 data = wxPrintData()
640 data.EnablePrintToFile(true)
641 data.EnablePageNumbers(true)
642 data.EnableSelection(true)
643 dlg = wxPrintDialog(self, data)
644 if dlg.ShowModal() == wxID_OK:
645 self.log.WriteText('\n')
646 dlg.Destroy()
647
648 def OnTestMessageDlg(self, event):
649 dlg = wxMessageDialog(self, 'Hello from Python and wxWindows!',
650 'A Message Box', wxOK | wxICON_INFORMATION)
651 dlg.ShowModal()
652 dlg.Destroy()
653
654
655 def OnTestNotebook(self, event):
656 win = TestNotebookWindow(self)
657 win.Show(true)
658
9c039d08
RD
659 def OnTestSplitter(self, event):
660 win = TestSplitterWindow(self)
661 win.Show(true)
662
663 def OnTestCustomStatusBar(self, event):
664 win = TestCustomStatusBar(self)
665 win.Show(true)
666
667 def OnTestToolBar(self, event):
668 win = TestToolBar(self, self)
669 win.Show(true)
670
671
7bf85405
RD
672#---------------------------------------------------------------------------
673
674
675class MyApp(wxApp):
676 def OnInit(self):
677 frame = AppFrame(NULL, -1, "Test 4: (lots of little tests...)")
678 frame.Show(true)
679 self.SetTopWindow(frame)
680 return true
681
682#---------------------------------------------------------------------------
683
684
685def main():
686 app = MyApp(0)
687 app.MainLoop()
688
689
690def t():
691 import pdb
692 pdb.run('main()')
693
21f4bf45
RD
694
695# for focused testing...
0d6f9504 696def main2():
21f4bf45
RD
697 class T2App(wxApp):
698 def OnInit(self):
699 frame = TestLayoutConstraints(NULL)
700 frame.Show(true)
701 self.SetTopWindow(frame)
0d6f9504 702 return true
21f4bf45
RD
703
704 app = T2App(0)
705 app.MainLoop()
706
0d6f9504
RD
707def t2():
708 import pdb
709 pdb.run('main2()')
710
21f4bf45
RD
711
712
7bf85405
RD
713if __name__ == '__main__':
714 main()
715
716
717#----------------------------------------------------------------------------
718#
719# $Log$
9c039d08
RD
720# Revision 1.5 1998/10/02 06:42:28 RD
721# Version 0.4 of wxPython for MSW.
722#
0d6f9504
RD
723# Revision 1.4 1998/08/27 21:59:51 RD
724# Some chicken-and-egg problems solved for wxPython on wxGTK
725#
21f4bf45
RD
726# Revision 1.3 1998/08/27 00:01:17 RD
727# - more tweaks
728# - have discovered some problems but not yet discovered solutions...
729#
f57d7932
RD
730# Revision 1.2 1998/08/22 19:51:18 RD
731# some tweaks for wxGTK
732#
7bf85405
RD
733# Revision 1.1 1998/08/09 08:28:05 RD
734# Initial version
735#
736#