]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/Main.py
Lots more Unicode fixes.
[wxWidgets.git] / wxPython / demo / Main.py
CommitLineData
cf694132
RD
1#!/bin/env python
2#----------------------------------------------------------------------------
3# Name: Main.py
4# Purpose: Testing lots of stuff, controls, window types, etc.
5#
f6bcfd97 6# Author: Robin Dunn
cf694132 7#
f6bcfd97 8# Created: A long time ago, in a galaxy far, far away...
cf694132
RD
9# RCS-ID: $Id$
10# Copyright: (c) 1999 by Total Control Software
11# Licence: wxWindows license
12#----------------------------------------------------------------------------
13
6c5ae2d2 14import sys, os, time, string
cf694132 15from wxPython.wx import *
f6bcfd97 16from wxPython.html import wxHtmlWindow
cf694132 17
774e63ef 18##from wxPython.stc import *
606d919c 19
96bfd053
RD
20import images
21
cf694132
RD
22#---------------------------------------------------------------------------
23
24
25_treeList = [
9c67cbec
RD
26 # new stuff
27 ('New since last release', [
28 'RowColSizer',
29 'Unicode',
30 'wxFileHistory',
31 'wxGenericDirCtrl',
32 'wxImageFromStream',
72797a7d 33 'wxArtProvider',
f9b24f07 34 'ScrolledPanel',
3115ef3e 35 'wxMenu',
c731eb47 36 'wxIEHtmlWin',
3b867149 37 'wxKeyEvents',
af83019e 38 'wxWizard',
9c67cbec
RD
39 ]),
40
41 # managed windows == things with a caption you can close
42 ('Base Frames and Dialogs', [
43 'wxDialog',
44 'wxFrame',
45 'wxMDIWindows',
46 'wxMiniFrame',
af83019e 47 'wxWizard',
9c67cbec
RD
48 ]),
49
50 # the common dialogs
51 ('Common Dialogs', [
52 'wxColourDialog',
53 'wxDirDialog',
54 'wxFileDialog',
55 'wxFindReplaceDialog',
56 'wxFontDialog',
57 'wxMessageDialog',
58 'wxPageSetupDialog',
59 'wxPrintDialog',
60 'wxProgressDialog',
61 'wxSingleChoiceDialog',
62 'wxTextEntryDialog',
63 ]),
64
af83019e 65 # dialogs from libraries
9c67cbec
RD
66 ('More Dialogs', [
67 'ErrorDialogs',
68 'ImageBrowser',
69 'wxMultipleChoiceDialog',
70 'wxScrolledMessageDialog',
71 ]),
72
73 # core controls
74 ('Core Windows/Controls', [
9c67cbec
RD
75 'wxButton',
76 'wxCheckBox',
77 'wxCheckListBox',
78 'wxChoice',
79 'wxComboBox',
80 'wxGauge',
81 'wxGenericDirCtrl',
82 'wxGrid',
83 'wxListBox',
84 'wxListCtrl',
6f48b1b5 85 'wxListCtrl_virtual',
3115ef3e 86 'wxMenu',
9c67cbec
RD
87 'wxNotebook',
88 'wxPopupWindow',
89 'wxRadioBox',
90 'wxSashWindow',
91 'wxSlider',
92 'wxScrolledWindow',
93 'wxSplitterWindow',
94 'wxSpinButton',
95 'wxSpinCtrl',
96 'wxStaticText',
97 'wxStaticBitmap',
98 'wxStatusBar',
99 'wxTextCtrl',
9c67cbec
RD
100 'wxToggleButton',
101 'wxToolBar',
102 'wxTreeCtrl',
103 'wxValidator',
104 ]),
105
106 # controls coming from other librairies
107 ('More Windows/Controls', [
108 'ColourSelect',
109 'ContextHelp',
110 'FancyText',
111 'FileBrowseButton',
112 'GenericButtons',
113 'PyCrust',
114 'PyCrustWithFilling',
115 'SplitTree',
116 'TablePrint',
117 'wxCalendar',
118 'wxCalendarCtrl',
119 'wxDynamicSashWindow',
120 'wxEditableListBox',
121 'wxEditor',
3b867149 122 #'wxFloatBar', deprecated
9c67cbec 123 'wxHtmlWindow',
c731eb47 124 'wxIEHtmlWin',
9c67cbec
RD
125 'wxLEDNumberCtrl',
126 'wxMimeTypesManager',
3b867149 127 #'wxMVCTree', deprecated
70a357c2 128 'wxRightTextCtrl',
9c67cbec
RD
129 'wxStyledTextCtrl_1',
130 'wxStyledTextCtrl_2',
9c67cbec
RD
131 ]),
132
133 # How to lay out the controls in a frame/dialog
134 ('Window Layout', [
135 'LayoutAnchors',
136 'Layoutf',
137 'RowColSizer',
f9b24f07 138 'ScrolledPanel',
9c67cbec
RD
139 'Sizers',
140 'wxLayoutConstraints',
141 'XML_Resource',
142 ]),
143
144 # ditto
145 ('Process and Events', [
146 'infoframe',
147 'OOR',
148 'PythonEvents',
149 'Threads',
150 'wxProcess',
151 'wxTimer',
3b867149 152 'wxKeyEvents',
9c67cbec
RD
153 ]),
154
155 # Clipboard and DnD
156 ('Clipboard and DnD', [
157 'CustomDragAndDrop',
158 'DragAndDrop',
159 'URLDragAndDrop',
160 ]),
161
162 # Images
163 ('Images', [
164 'wxDragImage',
165 'wxImage',
166 'wxImageFromStream',
167 'wxMask',
72797a7d 168 'wxArtProvider',
9c67cbec
RD
169 ]),
170
171 # Other stuff
172 ('Miscellaneous', [
173 'ColourDB',
174 'DialogUnits',
175 'DrawXXXList',
176 'FontEnumerator',
177 'PrintFramework',
178 'Unicode',
179 'wxFileHistory',
180 'wxJoystick',
181 'wxOGL',
182 'wxWave',
183 ]),
184
185 # need libs not coming with the demo
186 ('Objects using an external library', [
187 'ActiveXWrapper_Acrobat',
188 'ActiveXWrapper_IE',
189 'wxGLCanvas',
190 'wxPlotCanvas',
9c67cbec
RD
191 ]),
192
70a357c2 193
9c67cbec
RD
194 ('Check out the samples dir too', [
195 ]),
196
9c67cbec
RD
197]
198
199
cf694132
RD
200
201#---------------------------------------------------------------------------
202
76bfdc78
RD
203class MyLog(wxPyLog):
204 def __init__(self, textCtrl, logTime=0):
205 wxPyLog.__init__(self)
206 self.tc = textCtrl
207 self.logTime = logTime
208
209 def DoLogString(self, message, timeStamp):
210 if self.logTime:
211 message = time.strftime("%X", time.localtime(timeStamp)) + \
212 ": " + message
213 self.tc.AppendText(message + '\n')
214
215
861a0196
RD
216class MyTP(wxPyTipProvider):
217 def GetTip(self):
218 return "This is my tip"
219
6c5ae2d2
RD
220#---------------------------------------------------------------------------
221
222def opj(path):
223 """Convert paths to the platform-specific separator"""
224 return apply(os.path.join, tuple(string.split(path, '/')))
225
226
76bfdc78
RD
227#---------------------------------------------------------------------------
228
cf694132 229class wxPythonDemo(wxFrame):
e9159fe8 230 overviewText = "wxPython Overview"
c368d904 231
cf694132 232 def __init__(self, parent, id, title):
f6bcfd97
BP
233 wxFrame.__init__(self, parent, -1, title, size = (800, 600),
234 style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
2f90df85 235
694759cf 236 self.cwd = os.getcwd()
3ca6a5f0 237 self.curOverview = ""
694759cf 238
afb810d9 239 icon = images.getMondrianIcon()
96bfd053 240 self.SetIcon(icon)
c368d904 241
96bfd053 242 if wxPlatform == '__WXMSW__':
c368d904
RD
243 # setup a taskbar icon, and catch some events from it
244 self.tbicon = wxTaskBarIcon()
245 self.tbicon.SetIcon(icon, "wxPython Demo")
246 EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate)
247 EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarMenu)
248 EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
249 EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
250
cf694132
RD
251
252 self.otherWin = None
ccf691a4 253 self.showTip = true
cf694132 254 EVT_IDLE(self, self.OnIdle)
f6bcfd97 255 EVT_CLOSE(self, self.OnCloseWindow)
f3d9dc1d
RD
256 EVT_ICONIZE(self, self.OnIconfiy)
257 EVT_MAXIMIZE(self, self.OnMaximize)
cf694132
RD
258
259 self.Centre(wxBOTH)
260 self.CreateStatusBar(1, wxST_SIZEGRIP)
5a7823f5 261
f6bcfd97
BP
262 splitter = wxSplitterWindow(self, -1, style=wxNO_3D|wxSP_3D)
263 splitter2 = wxSplitterWindow(splitter, -1, style=wxNO_3D|wxSP_3D)
5a7823f5 264
d56cebe7
RD
265 def EmptyHandler(evt): pass
266 EVT_ERASE_BACKGROUND(splitter, EmptyHandler)
267 EVT_ERASE_BACKGROUND(splitter2, EmptyHandler)
cf694132 268
b1cfebd9 269 # Prevent TreeCtrl from displaying all items after destruction when true
cf694132
RD
270 self.dying = false
271
272 # Make a File menu
273 self.mainmenu = wxMenuBar()
274 menu = wxMenu()
2f90df85 275 exitID = wxNewId()
f0261a72 276 menu.Append(exitID, 'E&xit\tAlt-X', 'Get the heck outta here!')
2f90df85 277 EVT_MENU(self, exitID, self.OnFileExit)
cf694132
RD
278 self.mainmenu.Append(menu, '&File')
279
ec3e670f
RD
280 # Make a Demo menu
281 menu = wxMenu()
282 for item in _treeList:
283 submenu = wxMenu()
284 for childItem in item[1]:
285 mID = wxNewId()
286 submenu.Append(mID, childItem)
287 EVT_MENU(self, mID, self.OnDemoMenu)
288 menu.AppendMenu(wxNewId(), item[0], submenu)
289 self.mainmenu.Append(menu, '&Demo')
290
291
cf694132 292 # Make a Help menu
2f90df85 293 helpID = wxNewId()
cf694132 294 menu = wxMenu()
2f90df85
RD
295 menu.Append(helpID, '&About\tCtrl-H', 'wxPython RULES!!!')
296 EVT_MENU(self, helpID, self.OnHelpAbout)
cf694132
RD
297 self.mainmenu.Append(menu, '&Help')
298 self.SetMenuBar(self.mainmenu)
299
2f90df85 300 # set the menu accellerator table...
f0261a72 301 aTable = wxAcceleratorTable([(wxACCEL_ALT, ord('X'), exitID),
2f90df85
RD
302 (wxACCEL_CTRL, ord('H'), helpID)])
303 self.SetAcceleratorTable(aTable)
304
bb0054cd 305
cf694132 306 # Create a TreeCtrl
f6bcfd97
BP
307 tID = wxNewId()
308 self.treeMap = {}
309 self.tree = wxTreeCtrl(splitter, tID,
310 style=wxTR_HAS_BUTTONS |
eb0f373c
RD
311 wxTR_HAS_VARIABLE_ROW_HEIGHT
312 )
afb810d9 313
f6bcfd97 314 #self.tree.SetBackgroundColour(wxNamedColour("Pink"))
e9159fe8 315 root = self.tree.AddRoot("wxPython Overview")
f6bcfd97
BP
316 firstChild = None
317 for item in _treeList:
318 child = self.tree.AppendItem(root, item[0])
319 if not firstChild: firstChild = child
320 for childItem in item[1]:
321 theDemo = self.tree.AppendItem(child, childItem)
322 self.treeMap[childItem] = theDemo
323
324 self.tree.Expand(root)
325 self.tree.Expand(firstChild)
326 EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded)
327 EVT_TREE_ITEM_COLLAPSED (self.tree, tID, self.OnItemCollapsed)
328 EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged)
329 EVT_LEFT_DOWN (self.tree, self.OnTreeLeftDown)
cf694132 330
cf694132 331 # Create a Notebook
d56cebe7 332 self.nb = wxNotebook(splitter2, -1, style=wxCLIP_CHILDREN)
cf694132 333
c368d904 334 # Set up a wxHtmlWindow on the Overview Notebook page
0bdca46d
RD
335 # we put it in a panel first because there seems to be a
336 # refresh bug of some sort (wxGTK) when it is directly in
337 # the notebook...
338 if 0: # the old way
339 self.ovr = wxHtmlWindow(self.nb, -1, size=(400, 400))
340 self.nb.AddPage(self.ovr, self.overviewText)
341
342 else: # hopefully I can remove this hacky code soon, see bug #216861
343 panel = wxPanel(self.nb, -1, style=wxCLIP_CHILDREN)
344 self.ovr = wxHtmlWindow(panel, -1, size=(400, 400))
345 self.nb.AddPage(panel, self.overviewText)
346
347 def OnOvrSize(evt, ovr=self.ovr):
348 ovr.SetSize(evt.GetSize())
349
350 EVT_SIZE(panel, OnOvrSize)
351 EVT_ERASE_BACKGROUND(panel, EmptyHandler)
352
c368d904 353
e9159fe8 354 self.SetOverview(self.overviewText, overview)
cf694132
RD
355
356
357 # Set up a TextCtrl on the Demo Code Notebook page
efc5f224
RD
358 self.txt = wxTextCtrl(self.nb, -1,
359 style = wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
cf694132
RD
360 self.nb.AddPage(self.txt, "Demo Code")
361
362
cf694132 363 # Set up a log on the View Log Notebook page
f6bcfd97 364 self.log = wxTextCtrl(splitter2, -1,
efc5f224 365 style = wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
342639eb 366
f6bcfd97 367 # Set the wxWindows log target to be this textctrl
76bfdc78 368 #wxLog_SetActiveTarget(wxLogTextCtrl(self.log))
342639eb
RD
369
370 # But instead of the above we want to show how to use our own wxLog class
76bfdc78 371 wxLog_SetActiveTarget(MyLog(self.log))
cf694132 372
f9b24f07
RD
373 # for serious debugging
374 #wxLog_SetActiveTarget(wxLogStderr())
375 #wxLog_SetTraceMask(wxTraceMessages)
5a7823f5 376
f6bcfd97 377 self.Show(true)
5a7823f5 378
f9b24f07 379
f6bcfd97
BP
380 # add the windows to the splitter and split it.
381 splitter2.SplitHorizontally(self.nb, self.log)
f6bcfd97 382 splitter.SplitVertically(self.tree, splitter2)
afb810d9 383
f6bcfd97
BP
384 splitter.SetSashPosition(180, true)
385 splitter.SetMinimumPaneSize(20)
afb810d9
RD
386 splitter2.SetSashPosition(450, true)
387 splitter2.SetMinimumPaneSize(20)
388
cf694132 389
cf694132 390
bb0054cd
RD
391 # select initial items
392 self.nb.SetSelection(0)
f6bcfd97 393 self.tree.SelectItem(root)
ec3e670f
RD
394
395 if len(sys.argv) == 2:
396 try:
397 selectedDemo = self.treeMap[sys.argv[1]]
398 except:
399 selectedDemo = None
f6bcfd97 400 if selectedDemo:
ec3e670f
RD
401 self.tree.SelectItem(selectedDemo)
402 self.tree.EnsureVisible(selectedDemo)
403
bb0054cd 404
f6bcfd97 405 wxLogMessage('window handle: %s' % self.GetHandle())
2abc0a0f
RD
406
407
cf694132
RD
408 #---------------------------------------------
409 def WriteText(self, text):
f6bcfd97
BP
410 if text[-1:] == '\n':
411 text = text[:-1]
412 wxLogMessage(text)
413
cf694132
RD
414
415 def write(self, txt):
416 self.WriteText(txt)
417
418 #---------------------------------------------
419 def OnItemExpanded(self, event):
420 item = event.GetItem()
f6bcfd97 421 wxLogMessage("OnItemExpanded: %s" % self.tree.GetItemText(item))
c368d904 422 event.Skip()
cf694132
RD
423
424 #---------------------------------------------
425 def OnItemCollapsed(self, event):
426 item = event.GetItem()
f6bcfd97 427 wxLogMessage("OnItemCollapsed: %s" % self.tree.GetItemText(item))
c368d904 428 event.Skip()
f6bcfd97
BP
429
430 #---------------------------------------------
431 def OnTreeLeftDown(self, event):
432 pt = event.GetPosition();
433 item, flags = self.tree.HitTest(pt)
434 if item == self.tree.GetSelection():
d975da9b 435 self.SetOverview(self.tree.GetItemText(item)+" Overview", self.curOverview)
185d7c3e 436 event.Skip()
cf694132
RD
437
438 #---------------------------------------------
439 def OnSelChanged(self, event):
440 if self.dying:
441 return
442
5a7823f5
RD
443 item = event.GetItem()
444 itemText = self.tree.GetItemText(item)
445 self.RunDemo(itemText)
446
447
448 #---------------------------------------------
449 def RunDemo(self, itemText):
694759cf 450 os.chdir(self.cwd)
cf694132
RD
451 if self.nb.GetPageCount() == 3:
452 if self.nb.GetSelection() == 2:
453 self.nb.SetSelection(0)
454 self.nb.DeletePage(2)
455
e9159fe8 456 if itemText == self.overviewText:
cf694132 457 self.GetDemoFile('Main.py')
e9159fe8 458 self.SetOverview(self.overviewText, overview)
cf694132 459 self.nb.Refresh();
e91a9dfc 460 self.window = None
cf694132
RD
461
462 else:
463 if os.path.exists(itemText + '.py'):
9d8bd15f 464 wxBeginBusyCursor()
f6bcfd97
BP
465 wxLogMessage("Running demo %s.py..." % itemText)
466 try:
467 self.GetDemoFile(itemText + '.py')
468 module = __import__(itemText, globals())
e9159fe8 469 self.SetOverview(itemText + " Overview", module.overview)
f6bcfd97
BP
470 finally:
471 wxEndBusyCursor()
5a1eefc7 472 self.tree.Refresh()
cf694132
RD
473
474 # in case runTest is modal, make sure things look right...
475 self.nb.Refresh();
5a1eefc7 476 wxSafeYield()
cf694132 477
f6bcfd97 478 self.window = module.runTest(self, self.nb, self) ###
e91a9dfc
RD
479 if self.window:
480 self.nb.AddPage(self.window, 'Demo')
cf694132 481 self.nb.SetSelection(2)
eb28fd47 482 self.nb.Refresh() # without this wxMac has troubles showing the just added page
cf694132
RD
483
484 else:
f6bcfd97 485 self.ovr.SetPage("")
cf694132 486 self.txt.Clear()
e91a9dfc 487 self.window = None
cf694132 488
2f90df85 489
cf694132
RD
490
491 #---------------------------------------------
492 # Get the Demo files
493 def GetDemoFile(self, filename):
494 self.txt.Clear()
bb0054cd
RD
495 try:
496 self.txt.SetValue(open(filename).read())
8bf5d46e 497 except IOError:
cf694132
RD
498 self.txt.WriteText("Cannot open %s file." % filename)
499
500 self.txt.SetInsertionPoint(0)
501 self.txt.ShowPosition(0)
502
503 #---------------------------------------------
504 def SetOverview(self, name, text):
f6bcfd97
BP
505 self.curOverview = text
506 lead = text[:6]
507 if lead != '<html>' and lead != '<HTML>':
508 text = string.join(string.split(text, '\n'), '<br>')
f6bcfd97 509 self.ovr.SetPage(text)
cf694132 510 self.nb.SetPageText(0, name)
cf694132
RD
511
512 #---------------------------------------------
513 # Menu methods
c368d904 514 def OnFileExit(self, *event):
cf694132
RD
515 self.Close()
516
517
518 def OnHelpAbout(self, event):
e166644c 519 from About import MyAboutBox
ec3e670f 520 about = MyAboutBox(self)
cf694132
RD
521 about.ShowModal()
522 about.Destroy()
523
524
525 #---------------------------------------------
526 def OnCloseWindow(self, event):
527 self.dying = true
e91a9dfc 528 self.window = None
26197023 529 self.mainmenu = None
c368d904
RD
530 if hasattr(self, "tbicon"):
531 del self.tbicon
cf694132
RD
532 self.Destroy()
533
c368d904 534
cf694132
RD
535 #---------------------------------------------
536 def OnIdle(self, event):
537 if self.otherWin:
538 self.otherWin.Raise()
e91a9dfc 539 self.window = self.otherWin
cf694132
RD
540 self.otherWin = None
541
ccf691a4
RD
542 if self.showTip:
543 self.ShowTip()
544 self.showTip = false
545
546
547 #---------------------------------------------
548 def ShowTip(self):
549 try:
550 showTipText = open(opj("data/showTips")).read()
551 showTip, index = eval(showTipText)
552 except IOError:
553 showTip, index = (1, 0)
554 if showTip:
555 tp = wxCreateFileTipProvider(opj("data/tips.txt"), index)
861a0196 556 ##tp = MyTP(0)
ccf691a4
RD
557 showTip = wxShowTip(self, tp)
558 index = tp.GetCurrentTip()
559 open(opj("data/showTips"), "w").write(str( (showTip, index) ))
560
561
ec3e670f
RD
562 #---------------------------------------------
563 def OnDemoMenu(self, event):
f6bcfd97
BP
564 try:
565 selectedDemo = self.treeMap[self.mainmenu.GetLabel(event.GetId())]
566 except:
567 selectedDemo = None
568 if selectedDemo:
569 self.tree.SelectItem(selectedDemo)
570 self.tree.EnsureVisible(selectedDemo)
ec3e670f 571
c368d904
RD
572
573 #---------------------------------------------
574 def OnTaskBarActivate(self, evt):
575 if self.IsIconized():
576 self.Iconize(false)
577 if not self.IsShown():
578 self.Show(true)
579 self.Raise()
580
581 #---------------------------------------------
582
583 TBMENU_RESTORE = 1000
584 TBMENU_CLOSE = 1001
585
586 def OnTaskBarMenu(self, evt):
587 menu = wxMenu()
588 menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo")
589 menu.Append(self.TBMENU_CLOSE, "Close")
590 self.tbicon.PopupMenu(menu)
591 menu.Destroy()
592
593 #---------------------------------------------
594 def OnTaskBarClose(self, evt):
595 self.Close()
596
597 # because of the way wxTaskBarIcon.PopupMenu is implemented we have to
598 # prod the main idle handler a bit to get the window to actually close
599 wxGetApp().ProcessIdle()
600
601
f3d9dc1d
RD
602 #---------------------------------------------
603 def OnIconfiy(self, evt):
604 wxLogMessage("OnIconfiy")
605 evt.Skip()
606
607 #---------------------------------------------
608 def OnMaximize(self, evt):
609 wxLogMessage("OnMaximize")
610 evt.Skip()
611
612
613
614
cf694132
RD
615#---------------------------------------------------------------------------
616#---------------------------------------------------------------------------
617
b5a5d647
RD
618class MySplashScreen(wxSplashScreen):
619 def __init__(self):
6c5ae2d2 620 bmp = wxImage(opj("bitmaps/splash.gif")).ConvertToBitmap()
b5a5d647
RD
621 wxSplashScreen.__init__(self, bmp,
622 wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
40c4c5a3
RD
623 4000, None, -1,
624 style = wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP)
b5a5d647
RD
625 EVT_CLOSE(self, self.OnClose)
626
627 def OnClose(self, evt):
9fb56e0c 628 frame = wxPythonDemo(None, -1, "wxPython: (A Demonstration)")
cf694132 629 frame.Show(true)
ccf691a4 630 evt.Skip() # Make sure the default handler runs too...
cf694132 631
b5a5d647
RD
632
633class MyApp(wxApp):
634 def OnInit(self):
635 """
68320e40 636 Create and show the splash screen. It will then create and show
b5a5d647
RD
637 the main frame when it is time to do so.
638 """
639 wxInitAllImageHandlers()
640 splash = MySplashScreen()
641 splash.Show()
b5a5d647
RD
642 return true
643
644
645
cf694132
RD
646#---------------------------------------------------------------------------
647
648def main():
e02c03a4 649 try:
d56cebe7 650 demoPath = os.path.dirname(__file__)
e02c03a4
RD
651 os.chdir(demoPath)
652 except:
653 pass
606d919c 654 app = MyApp(wxPlatform == "__WXMAC__")
cf694132
RD
655 app.MainLoop()
656
657
658#---------------------------------------------------------------------------
659
660
661
f6bcfd97
BP
662overview = """<html><body>
663 <h2>Python</h2>
664
665 Python is an interpreted, interactive, object-oriented programming
666 language often compared to Tcl, Perl, Scheme, or Java.
667
668 <p> Python combines remarkable power with very clear syntax. It has
669 modules, classes, exceptions, very high level dynamic data types, and
670 dynamic typing. There are interfaces to many system calls and
671 libraries, and new built-in modules are easily written in C or
672 C++. Python is also usable as an extension language for applications
673 that need a programmable interface. <p>
674
675 <h2>wxWindows</h2>
676
677 wxWindows is a free C++ framework designed to make cross-platform
678 programming child's play. Well, almost. wxWindows 2 supports Windows
679 3.1/95/98/NT, Unix with GTK/Motif/Lesstif, with a Mac version
680 underway. Other ports are under consideration. <p>
681
682 wxWindows is a set of libraries that allows C++ applications to
683 compile and run on several different types of computers, with minimal
684 source code changes. There is one library per supported GUI (such as
685 Motif, or Windows). As well as providing a common API (Application
686 Programming Interface) for GUI functionality, it provides
687 functionality for accessing some commonly-used operating system
688 facilities, such as copying or deleting files. wxWindows is a
689 'framework' in the sense that it provides a lot of built-in
690 functionality, which the application can use or replace as required,
691 thus saving a great deal of coding effort. Basic data structures such
692 as strings, linked lists and hash tables are also supported.
693
694 <p>
695 <h2>wxPython</h2>
696
697 wxPython is a Python extension module that encapsulates the wxWindows
698 GUI classes. Currently it is only available for the Win32 and GTK
699 ports of wxWindows, but as soon as the other ports are brought up to
700 the same level as Win32 and GTK, it should be fairly trivial to
701 enable wxPython to be used with the new GUI.
702
703 <p>
704
705 The wxPython extension module attempts to mirror the class heiarchy
706 of wxWindows as closely as possible. This means that there is a
707 wxFrame class in wxPython that looks, smells, tastes and acts almost
708 the same as the wxFrame class in the C++ version. Unfortunately,
709 because of differences in the languages, wxPython doesn't match
710 wxWindows exactly, but the differences should be easy to absorb
711 because they are natural to Python. For example, some methods that
712 return multiple values via argument pointers in C++ will return a
713 tuple of values in Python.
714
715 <p>
716
717 There is still much to be done for wxPython, many classes still need
718 to be mirrored. Also, wxWindows is still somewhat of a moving target
719 so it is a bit of an effort just keeping wxPython up to date. On the
720 other hand, there are enough of the core classes completed that
721 useful applications can be written.
722
723 <p>
724
725 wxPython is close enough to the C++ version that the majority of
726 the wxPython documentation is actually just notes attached to the C++
727 documents that describe the places where wxPython is different. There
728 is also a series of sample programs included, and a series of
729 documentation pages that assist the programmer in getting started
730 with wxPython.
731
732 """
cf694132
RD
733
734
735#----------------------------------------------------------------------------
736#----------------------------------------------------------------------------
737
738if __name__ == '__main__':
739 main()
740
741#----------------------------------------------------------------------------
742
743
744
745
746
747
748