2 #----------------------------------------------------------------------------
4 # Purpose: Testing lots of stuff, controls, window types, etc.
10 # Copyright: (c) 1998 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------------
15 from wxPython
.wx
import *
19 #---------------------------------------------------------------------------
21 class TestSimpleControlsDlg(wxDialog
):
22 def __init__(self
, parent
, log
):
24 wxDialog
.__init
__(self
, parent
, -1, "Test Simple Controls",
25 wxPyDefaultPosition
, wxSize(350, 350))
28 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
29 'six', 'seven', 'eight']
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
)
39 wxCheckBox(self
, 20, "wxCheckBox", wxPoint(80, y_pos
), wxSize(150, 20), wxNO_BORDER
)
40 EVT_CHECKBOX(self
, 20, self
.EvtCheckBox
)
43 rb
= wxRadioBox(self
, 30, "wxRadioBox", wxPoint(80, y_pos
), wxPyDefaultSize
,
44 sampleList
, 3, wxRA_HORIZONTAL| wxNO_BORDER
)
45 EVT_RADIOBOX(self
, 30, self
.EvtRadioBox
)
46 width
, height
= rb
.GetSizeTuple()
47 y_pos
= y_pos
+ height
+ 5
49 wxStaticText(self
, -1, "wxChoice", wxPoint(5, y_pos
), wxSize(75, 20))
50 wxChoice(self
, 40, wxPoint(80, y_pos
), wxSize(95, 20), #wxPyDefaultSize,
52 EVT_CHOICE(self
, 40, self
.EvtChoice
)
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
)
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
)
67 width
, height
= lb
.GetSizeTuple()
68 y_pos
= y_pos
+ height
+ 5
73 wxButton(self
, wxID_OK
, ' OK ', wxPoint(80, y_pos
), wxPyDefaultSize
).SetDefault()
74 wxButton(self
, wxID_CANCEL
, ' Cancel ', wxPoint(140, y_pos
))
77 def EvtText(self
, event
):
78 self
.log
.WriteText('EvtText: %s\n' % event
.GetString())
80 def EvtCheckBox(self
, event
):
81 self
.log
.WriteText('EvtCheckBox: %d\n' % event
.GetInt())
83 def EvtRadioBox(self
, event
):
84 self
.log
.WriteText('EvtRadioBox: %d\n' % event
.GetInt())
86 def EvtChoice(self
, event
):
87 self
.log
.WriteText('EvtChoice: %s\n' % event
.GetString())
89 def EvtComboBox(self
, event
):
90 self
.log
.WriteText('EvtComboBox: %s\n' % event
.GetString())
92 def EvtListBox(self
, event
):
93 self
.log
.WriteText('EvtListBox: %s\n' % event
.GetString())
95 def EvtListBoxDClick(self
, event
):
96 self
.log
.WriteText('EvtListBoxDClick:\n')
100 #---------------------------------------------------------------------------
102 class TestTimer(wxTimer
):
103 def __init__(self
, log
):
104 wxTimer
.__init
__(self
)
109 self
.log
.WriteText('beep!\n')
112 #---------------------------------------------------------------------------
114 class TestLayoutConstraints(wxFrame
):
115 def __init__(self
, parent
):
116 wxFrame
.__init
__(self
, parent
, -1, 'Test Layout Constraints',
117 wxPyDefaultPosition
, wxSize(500, 300))
119 self
.SetAutoLayout(true
)
120 EVT_BUTTON(self
, 100, self
.OnButton
)
122 self
.panelA
= wxWindow(self
, -1, wxPyDefaultPosition
, wxPyDefaultSize
,
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
)
132 self
.panelB
= wxWindow(self
, -1, wxPyDefaultPosition
, wxPyDefaultSize
,
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
)
142 self
.panelC
= wxWindow(self
, -1, wxPyDefaultPosition
, wxPyDefaultSize
,
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
)
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
)
157 lc
.width
.PercentOf (self
.panelA
, wxWidth
, 50)
158 b
.SetConstraints(lc
);
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)
166 b
.SetConstraints(lc
);
168 self
.panelD
= wxWindow(self
.panelC
, -1, wxPyDefaultPosition
, wxPyDefaultSize
,
170 self
.panelD
.SetBackgroundColour(wxGREEN
)
171 wxStaticText(self
.panelD
, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN
)
173 b
= wxButton(self
.panelC
, 100, ' Panel C ')
174 lc
= wxLayoutConstraints()
175 lc
.top
.Below (self
.panelD
)
176 lc
.left
.RightOf (self
.panelD
)
179 b
.SetConstraints(lc
);
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
);
189 def OnButton(self
, event
):
193 def OnCloseWindow(self
, event
):
197 #---------------------------------------------------------------------------
199 class TestGrid(wxFrame
):
200 def __init__(self
, parent
, log
):
201 wxFrame
.__init
__(self
, parent
, -1, 'Test Grid',
202 wxPyDefaultPosition
, wxSize(500, 300))
205 grid
= wxGrid(self
, -1)
207 grid
.CreateGrid(16, 16)
208 grid
.SetColumnWidth(3, 200)
209 grid
.SetRowHeight(4, 45)
210 grid
.SetCellValue("First cell", 0, 0)
211 grid
.SetCellValue("Another cell", 1, 1)
212 grid
.SetCellValue("Yet another cell", 2, 2)
213 grid
.SetCellTextFont(wxFont(12, wxROMAN
, wxITALIC
, wxNORMAL
), 0, 0)
214 grid
.SetCellTextColour(wxRED
, 1, 1)
215 grid
.SetCellBackgroundColour(wxCYAN
, 2, 2)
216 grid
.UpdateDimensions()
217 grid
.AdjustScrollbars()
219 EVT_GRID_SELECT_CELL(grid
, self
.OnSelectCell
)
220 EVT_GRID_CELL_CHANGE(grid
, self
.OnCellChange
)
221 EVT_GRID_CELL_LCLICK(grid
, self
.OnCellClick
)
222 EVT_GRID_LABEL_LCLICK(grid
, self
.OnLabelClick
)
226 def OnCloseWindow(self
, event
):
229 def OnSelectCell(self
, event
):
230 self
.log
.WriteText("OnSelectCell: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
232 def OnCellChange(self
, event
):
233 self
.log
.WriteText("OnCellChange: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
235 def OnCellClick(self
, event
):
236 self
.log
.WriteText("OnCellClick: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
238 def OnLabelClick(self
, event
):
239 self
.log
.WriteText("OnLabelClick: (%d, %d)\n" % (event
.m_row
, event
.m_col
))
241 #---------------------------------------------------------------------------
244 class ColoredPanel(wxWindow
):
245 def __init__(self
, parent
, color
):
246 wxWindow
.__init
__(self
, parent
, -1,
247 wxPyDefaultPosition
, wxPyDefaultSize
, wxRAISED_BORDER
)
248 self
.SetBackgroundColour(color
)
251 class TestNotebookWindow(wxFrame
):
252 def __init__(self
, parent
, log
):
253 wxFrame
.__init
__(self
, parent
, -1, 'Test wxNotebook',
254 wxPyDefaultPosition
, wxPyDefaultSize
)
256 nb
= wxNotebook(self
, -1)
258 win
= ColoredPanel(nb
, wxBLUE
)
259 nb
.AddPage(win
, "Blue")
260 st
= wxStaticText(win
, -1,
261 "You can put nearly any type of window here!",
263 st
.SetForegroundColour(wxWHITE
)
264 st
.SetBackgroundColour(wxBLUE
)
265 st
= wxStaticText(win
, -1,
266 "Check the next tab for an example...",
268 st
.SetForegroundColour(wxWHITE
)
269 st
.SetBackgroundColour(wxBLUE
)
271 win
= TestTreeCtrlPanel(nb
, log
)
272 nb
.AddPage(win
, "TreeCtrl")
274 win
= ColoredPanel(nb
, wxRED
)
275 nb
.AddPage(win
, "Red")
277 win
= ColoredPanel(nb
, wxGREEN
)
278 nb
.AddPage(win
, "Green")
280 win
= ColoredPanel(nb
, wxCYAN
)
281 nb
.AddPage(win
, "Cyan")
283 win
= ColoredPanel(nb
, wxWHITE
)
284 nb
.AddPage(win
, "White")
286 win
= ColoredPanel(nb
, wxBLACK
)
287 nb
.AddPage(win
, "Black")
289 win
= ColoredPanel(nb
, wxNamedColour('MIDNIGHT BLUE'))
290 nb
.AddPage(win
, "MIDNIGHT BLUE")
292 win
= ColoredPanel(nb
, wxNamedColour('INDIAN RED'))
293 nb
.AddPage(win
, "INDIAN RED")
297 self
.SetSize(wxSize(350, 300)) # force a redraw so the notebook will draw
300 def OnCloseWindow(self
, event
):
303 #---------------------------------------------------------------------------
305 class TestSplitterWindow(wxFrame
):
306 def __init__(self
, parent
):
307 wxFrame
.__init
__(self
, parent
, -1, 'Test wxSplitterWindow',
308 wxPyDefaultPosition
, wxSize(500, 300))
310 splitter
= wxSplitterWindow(self
, -1)
312 p1
= ColoredPanel(splitter
, wxRED
)
313 wxStaticText(p1
, -1, "Panel One", wxPoint(5,5)).SetBackgroundColour(wxRED
)
315 p2
= ColoredPanel(splitter
, wxBLUE
)
316 wxStaticText(p2
, -1, "Panel Two", wxPoint(5,5)).SetBackgroundColour(wxBLUE
)
318 splitter
.SplitVertically(p1
, p2
)
321 def OnCloseWindow(self
, event
):
325 #---------------------------------------------------------------------------
327 class CustomStatusBar(wxStatusBar
):
328 def __init__(self
, parent
):
329 wxStatusBar
.__init
__(self
, parent
, -1)
330 self
.SetFieldsCount(3)
332 self
.SetStatusText("A Custom StatusBar...", 0)
334 self
.cb
= wxCheckBox(self
, 1001, "toggle clock")
335 EVT_CHECKBOX(self
, 1001, self
.OnToggleClock
)
336 self
.cb
.SetValue(true
)
338 # figure out how tall to make it.
339 dc
= wxClientDC(self
)
340 dc
.SetFont(self
.GetFont())
341 (w
,h
, d
,e
) = dc
.GetTextExtent('X')
343 self
.SetSize(wxSize(100, h
))
346 self
.timer
= wxPyTimer(self
.Notify
)
347 self
.timer
.Start(1000)
353 t
= time
.localtime(time
.time())
354 st
= time
.strftime("%d-%b-%Y %I:%M:%S", t
)
355 self
.SetStatusText(st
, 2)
357 # the checkbox was clicked
358 def OnToggleClock(self
, event
):
359 if self
.cb
.GetValue():
360 self
.timer
.Start(1000)
365 # reposition the checkbox
366 def OnSize(self
, event
):
367 rect
= self
.GetFieldRect(1)
368 self
.cb
.SetPosition(wxPoint(rect
.x
+2, rect
.y
+2))
369 self
.cb
.SetSize(wxSize(rect
.width
-4, rect
.height
-4))
373 class TestCustomStatusBar(wxFrame
):
374 def __init__(self
, parent
):
375 wxFrame
.__init
__(self
, parent
, -1, 'Test Custom StatusBar',
376 wxPyDefaultPosition
, wxSize(500, 300))
377 wxWindow(self
, -1).SetBackgroundColour(wxNamedColour("WHITE"))
379 self
.sb
= CustomStatusBar(self
)
380 self
.SetStatusBar(self
.sb
)
382 def OnCloseWindow(self
, event
):
387 #---------------------------------------------------------------------------
389 class TestToolBar(wxFrame
):
390 def __init__(self
, parent
, log
):
391 wxFrame
.__init
__(self
, parent
, -1, 'Test ToolBar',
392 wxPyDefaultPosition
, wxSize(500, 300))
395 wxWindow(self
, -1).SetBackgroundColour(wxNamedColour("WHITE"))
397 tb
= self
.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER
)
398 #tb = wxToolBar(self, -1, wxPyDefaultPosition, wxPyDefaultSize,
399 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
402 tb
.AddTool(10, wxNoRefBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP
),
403 NULL
, false
, -1, -1, "New")
404 EVT_TOOL(self
, 10, self
.OnToolClick
)
405 EVT_TOOL_RCLICKED(self
, 10, self
.OnToolRClick
)
407 tb
.AddTool(20, wxNoRefBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP
),
408 NULL
, false
, -1, -1, "Open")
409 EVT_TOOL(self
, 20, self
.OnToolClick
)
410 EVT_TOOL_RCLICKED(self
, 20, self
.OnToolRClick
)
413 tb
.AddTool(30, wxNoRefBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP
),
414 NULL
, false
, -1, -1, "Copy")
415 EVT_TOOL(self
, 30, self
.OnToolClick
)
416 EVT_TOOL_RCLICKED(self
, 30, self
.OnToolRClick
)
418 tb
.AddTool(40, wxNoRefBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP
),
419 NULL
, false
, -1, -1, "Paste")
420 EVT_TOOL(self
, 40, self
.OnToolClick
)
421 EVT_TOOL_RCLICKED(self
, 40, self
.OnToolRClick
)
425 tb
.AddTool(50, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP
),
426 NULL
, true
, -1, -1, "Toggle this")
427 EVT_TOOL(self
, 50, self
.OnToolClick
)
428 EVT_TOOL_RCLICKED(self
, 50, self
.OnToolRClick
)
430 tb
.AddTool(60, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP
),
431 wxNoRefBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP
),
432 true
, -1, -1, "Toggle with 2 bitmaps")
433 EVT_TOOL(self
, 60, self
.OnToolClick
)
434 EVT_TOOL_RCLICKED(self
, 60, self
.OnToolRClick
)
439 def OnCloseWindow(self
, event
):
442 def OnToolClick(self
, event
):
443 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
445 def OnToolRClick(self
, event
):
446 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
449 #---------------------------------------------------------------------------
451 class TestTreeCtrlPanel(wxPanel
):
452 def __init__(self
, parent
, log
):
453 wxPanel
.__init
__(self
, parent
, -1)
458 self
.tree
= wxTreeCtrl(self
, tID
)
459 root
= self
.tree
.AddRoot("The Root Item")
461 child
= self
.tree
.AppendItem(root
, "Item %d" % x
)
463 last
= self
.tree
.AppendItem(child
, "item %d-%s" % (x
, chr(ord("a")+y
)))
465 self
.tree
.Expand(root
)
466 EVT_TREE_ITEM_EXPANDED (self
, tID
, self
.OnItemExpanded
)
467 EVT_TREE_ITEM_COLLAPSED (self
, tID
, self
.OnItemCollapsed
)
468 EVT_TREE_SEL_CHANGED (self
, tID
, self
.OnSelChanged
)
471 def OnSize(self
, event
):
472 w
,h
= self
.GetClientSizeTuple()
473 self
.tree
.SetDimensions(0, 0, w
, h
)
476 def OnItemExpanded(self
, event
):
477 item
= event
.GetItem()
478 self
.log
.WriteText("OnItemExpanded: %s\n" % self
.tree
.GetItemText(item
))
480 def OnItemCollapsed(self
, event
):
481 item
= event
.GetItem()
482 self
.log
.WriteText("OnItemCollapsed: %s\n" % self
.tree
.GetItemText(item
))
484 def OnSelChanged(self
, event
):
485 item
= event
.GetItem()
486 self
.log
.WriteText("OnSelChanged: %s\n" % self
.tree
.GetItemText(item
))
491 class TestTreeCtrl(wxFrame
):
492 def __init__(self
, parent
, log
):
493 wxFrame
.__init
__(self
, parent
, -1, 'Test TreeCtrl',
494 wxPyDefaultPosition
, wxSize(250, 300))
496 p
= TestTreeCtrlPanel(self
, log
)
499 #---------------------------------------------------------------------------
500 #---------------------------------------------------------------------------
501 #---------------------------------------------------------------------------
503 class AppFrame(wxFrame
):
504 def __init__(self
, parent
, id, title
):
505 wxFrame
.__init
__(self
, parent
, id, title
, wxPyDefaultPosition
,
507 if wxPlatform
== '__WXMSW__':
508 self
.icon
= wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO
)
509 self
.SetIcon(self
.icon
)
511 self
.mainmenu
= wxMenuBar()
513 menu
.Append(200, 'E&xit', 'Get the heck outta here!')
514 EVT_MENU(self
, 200, self
.OnFileExit
)
515 self
.mainmenu
.Append(menu
, '&File')
517 menu
= self
.MakeTestsMenu()
518 self
.mainmenu
.Append(menu
, '&Tests')
519 self
.SetMenuBar(self
.mainmenu
)
521 self
.log
= wxTextCtrl(self
, -1, '', wxPyDefaultPosition
, wxPyDefaultSize
,
522 wxTE_MULTILINE|wxTE_READONLY
)
523 self
.log
.WriteText('Test 4:\n')
524 (w
, self
.charHeight
) = self
.log
.GetTextExtent('X')
527 def MakeTestsMenu(self
):
531 menu
.Append(mID
, '&Simple Controls')
532 EVT_MENU(self
, mID
, self
.OnTestSimpleControls
)
535 menu
.Append(mID
, '&Timer', '', true
)
536 EVT_MENU(self
, mID
, self
.OnTestTimer
)
541 menu
.Append(mID
, '&Layout Constraints')
542 EVT_MENU(self
, mID
, self
.OnTestLayoutConstraints
)
545 menu
.Append(mID
, '&Grid')
546 EVT_MENU(self
, mID
, self
.OnTestGrid
)
549 smenu
= wxMenu() # make a sub-menu
552 smenu
.Append(mID
, '&Colour')
553 EVT_MENU(self
, mID
, self
.OnTestColourDlg
)
556 smenu
.Append(mID
, '&Directory')
557 EVT_MENU(self
, mID
, self
.OnTestDirDlg
)
560 smenu
.Append(mID
, '&File')
561 EVT_MENU(self
, mID
, self
.OnTestFileDlg
)
564 smenu
.Append(mID
, '&Single Choice')
565 EVT_MENU(self
, mID
, self
.OnTestSingleChoiceDlg
)
568 smenu
.Append(mID
, '&TextEntry')
569 EVT_MENU(self
, mID
, self
.OnTestTextEntryDlg
)
572 smenu
.Append(mID
, '&Font')
573 EVT_MENU(self
, mID
, self
.OnTestFontDlg
)
576 smenu
.Append(mID
, '&PageSetup')
577 EVT_MENU(self
, mID
, self
.OnTestPageSetupDlg
)
580 smenu
.Append(mID
, '&Print')
581 EVT_MENU(self
, mID
, self
.OnTestPrintDlg
)
584 smenu
.Append(mID
, '&Message')
585 EVT_MENU(self
, mID
, self
.OnTestMessageDlg
)
588 menu
.AppendMenu(NewId(), '&Common Dialogs', smenu
)
592 menu
.Append(mID
, '&Notebook')
593 EVT_MENU(self
, mID
, self
.OnTestNotebook
)
596 menu
.Append(mID
, '&Splitter Window')
597 EVT_MENU(self
, mID
, self
.OnTestSplitter
)
600 menu
.Append(mID
, '&Custom StatusBar')
601 EVT_MENU(self
, mID
, self
.OnTestCustomStatusBar
)
604 menu
.Append(mID
, '&ToolBar')
605 EVT_MENU(self
, mID
, self
.OnTestToolBar
)
608 menu
.Append(mID
, 'T&ree Control')
609 EVT_MENU(self
, mID
, self
.OnTestTreeCtrl
)
616 def WriteText(self
, str):
617 self
.log
.WriteText(str)
618 if wxPlatform
== '__WXMSW__':
619 w
, h
= self
.log
.GetClientSizeTuple()
620 numLines
= h
/self
.charHeight
621 x
, y
= self
.log
.PositionToXY(self
.log
.GetLastPosition())
622 self
.log
.ShowPosition(self
.log
.XYToPosition(x
, y
-numLines
+1))
624 def OnFileExit(self
, event
):
627 def OnCloseWindow(self
, event
):
633 def OnTestSimpleControls(self
, event
):
634 dlg
= TestSimpleControlsDlg(self
, self
)
639 def OnTestTimer(self
, event
):
641 self
.mainmenu
.Check(self
.timerID
, false
)
645 self
.mainmenu
.Check(self
.timerID
, true
)
646 self
.timer
= TestTimer(self
)
647 self
.timer
.Start(1000)
649 def OnTestLayoutConstraints(self
, event
):
650 win
= TestLayoutConstraints(self
)
653 def OnTestGrid(self
, event
):
654 win
= TestGrid(self
, self
)
656 win
.SetSize(wxSize(505, 300)) # have to force a resize, or the grid doesn't
657 # show up for some reason....
659 def OnTestColourDlg(self
, event
):
660 data
= wxColourData()
661 data
.SetChooseFull(true
)
662 dlg
= wxColourDialog(self
, data
)
663 if dlg
.ShowModal() == wxID_OK
:
664 data
= dlg
.GetColourData()
665 self
.log
.WriteText('You selected: %s\n' % str(data
.GetColour().Get()))
668 def OnTestDirDlg(self
, event
):
669 dlg
= wxDirDialog(self
)
670 if dlg
.ShowModal() == wxID_OK
:
671 self
.log
.WriteText('You selected: %s\n' % dlg
.GetPath())
674 def OnTestFileDlg(self
, event
):
675 dlg
= wxFileDialog(self
, "Choose a file", ".", "", "*.*", wxOPEN
)
676 if dlg
.ShowModal() == wxID_OK
:
677 self
.log
.WriteText('You selected: %s\n' % dlg
.GetPath())
680 def OnTestSingleChoiceDlg(self
, event
):
681 dlg
= wxSingleChoiceDialog(self
, 'Test Single Choice', 'The Caption',
682 ['zero', 'one', 'two', 'three', 'four', 'five',
683 'six', 'seven', 'eight'])
684 if dlg
.ShowModal() == wxID_OK
:
685 self
.log
.WriteText('You selected: %s\n' % dlg
.GetStringSelection())
688 def OnTestTextEntryDlg(self
, event
):
689 dlg
= wxTextEntryDialog(self
, 'What is your favorite programming language?',
691 #dlg.SetValue("Python is the best!") #### this doesn't work?
692 if dlg
.ShowModal() == wxID_OK
:
693 self
.log
.WriteText('You entered: %s\n' % dlg
.GetValue())
697 def OnTestFontDlg(self
, event
):
698 dlg
= wxFontDialog(self
)
699 if dlg
.ShowModal() == wxID_OK
:
700 data
= dlg
.GetFontData()
701 font
= data
.GetChosenFont()
702 self
.log
.WriteText('You selected: "%s", %d points, color %s\n' %
703 (font
.GetFaceName(), font
.GetPointSize(),
704 data
.GetColour().Get()))
708 def OnTestPageSetupDlg(self
, event
):
709 data
= wxPageSetupData()
710 data
.SetMarginTopLeft(wxPoint(50,50))
711 data
.SetMarginBottomRight(wxPoint(50,50))
712 dlg
= wxPageSetupDialog(self
, data
)
713 if dlg
.ShowModal() == wxID_OK
:
714 data
= dlg
.GetPageSetupData()
715 tl
= data
.GetMarginTopLeft()
716 br
= data
.GetMarginBottomRight()
717 self
.log
.WriteText('Margins are: %s %s\n' % (str(tl
), str(br
)))
720 def OnTestPrintDlg(self
, event
):
722 data
.EnablePrintToFile(true
)
723 data
.EnablePageNumbers(true
)
724 data
.EnableSelection(true
)
725 dlg
= wxPrintDialog(self
, data
)
726 if dlg
.ShowModal() == wxID_OK
:
727 self
.log
.WriteText('\n')
730 def OnTestMessageDlg(self
, event
):
731 dlg
= wxMessageDialog(self
, 'Hello from Python and wxWindows!',
732 'A Message Box', wxOK | wxICON_INFORMATION
)
737 def OnTestNotebook(self
, event
):
738 win
= TestNotebookWindow(self
, self
)
741 def OnTestSplitter(self
, event
):
742 win
= TestSplitterWindow(self
)
745 def OnTestCustomStatusBar(self
, event
):
746 win
= TestCustomStatusBar(self
)
749 def OnTestToolBar(self
, event
):
750 win
= TestToolBar(self
, self
)
753 def OnTestTreeCtrl(self
, event
):
754 win
= TestTreeCtrl(self
, self
)
758 #---------------------------------------------------------------------------
763 frame
= AppFrame(NULL
, -1, "Test 4: (lots of little tests...)")
765 self
.SetTopWindow(frame
)
768 #---------------------------------------------------------------------------
781 # for focused testing...
785 frame
= TestLayoutConstraints(NULL
)
787 self
.SetTopWindow(frame
)
799 if __name__
== '__main__':
803 #----------------------------------------------------------------------------
806 # Revision 1.9 1998/12/15 20:44:35 RD
807 # Changed the import semantics from "from wxPython import *" to "from
808 # wxPython.wx import *" This is for people who are worried about
809 # namespace pollution, they can use "from wxPython import wx" and then
810 # prefix all the wxPython identifiers with "wx."
812 # Added wxTaskbarIcon for wxMSW.
814 # Made the events work for wxGrid.
818 # Added wxMiniFrame for wxGTK, (untested.)
820 # Changed many of the args and return values that were pointers to gdi
821 # objects to references to reflect changes in the wxWindows API.
823 # Other assorted fixes and additions.
825 # Revision 1.8 1998/11/25 08:47:11 RD
827 # Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
828 # Added events for wxGrid
829 # Other various fixes and additions
831 # Revision 1.7 1998/11/11 03:13:19 RD
833 # Additions for wxTreeCtrl
835 # Revision 1.6 1998/10/20 06:45:33 RD
836 # New wxTreeCtrl wrappers (untested)
837 # some changes in helpers
840 # Revision 1.5 1998/10/02 06:42:28 RD
842 # Version 0.4 of wxPython for MSW.
844 # Revision 1.4 1998/08/27 21:59:51 RD
845 # Some chicken-and-egg problems solved for wxPython on wxGTK
847 # Revision 1.3 1998/08/27 00:01:17 RD
849 # - have discovered some problems but not yet discovered solutions...
851 # Revision 1.2 1998/08/22 19:51:18 RD
852 # some tweaks for wxGTK
854 # Revision 1.1 1998/08/09 08:28:05 RD