1999-04-30 03:29:54 +00:00
|
|
|
#!/bin/env python
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
# Name: Main.py
|
|
|
|
# Purpose: Testing lots of stuff, controls, window types, etc.
|
|
|
|
#
|
2000-07-15 19:51:35 +00:00
|
|
|
# Author: Robin Dunn
|
1999-04-30 03:29:54 +00:00
|
|
|
#
|
2000-07-15 19:51:35 +00:00
|
|
|
# Created: A long time ago, in a galaxy far, far away...
|
1999-04-30 03:29:54 +00:00
|
|
|
# RCS-ID: $Id$
|
|
|
|
# Copyright: (c) 1999 by Total Control Software
|
|
|
|
# Licence: wxWindows license
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
import sys, os, time
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
import wx # This module uses the new wx namespace
|
|
|
|
import wx.html
|
2002-05-14 07:49:05 +00:00
|
|
|
|
2001-04-09 19:36:36 +00:00
|
|
|
import images
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
_treeList = [
|
2002-04-18 05:43:08 +00:00
|
|
|
# new stuff
|
2003-03-25 06:35:27 +00:00
|
|
|
('Recent Additions', [
|
2003-08-08 21:32:52 +00:00
|
|
|
'wxVListBox',
|
2002-04-18 05:43:08 +00:00
|
|
|
]),
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
# managed windows == things with a (optional) caption you can close
|
2002-04-18 05:43:08 +00:00
|
|
|
('Base Frames and Dialogs', [
|
|
|
|
'wxDialog',
|
|
|
|
'wxFrame',
|
|
|
|
'wxMDIWindows',
|
|
|
|
'wxMiniFrame',
|
2002-08-17 19:08:21 +00:00
|
|
|
'wxWizard',
|
2002-04-18 05:43:08 +00:00
|
|
|
]),
|
|
|
|
|
|
|
|
# the common dialogs
|
|
|
|
('Common Dialogs', [
|
|
|
|
'wxColourDialog',
|
|
|
|
'wxDirDialog',
|
|
|
|
'wxFileDialog',
|
2003-07-02 23:13:10 +00:00
|
|
|
'wxFileDialog_Save',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxFindReplaceDialog',
|
|
|
|
'wxFontDialog',
|
|
|
|
'wxMessageDialog',
|
|
|
|
'wxPageSetupDialog',
|
|
|
|
'wxPrintDialog',
|
|
|
|
'wxProgressDialog',
|
|
|
|
'wxSingleChoiceDialog',
|
|
|
|
'wxTextEntryDialog',
|
|
|
|
]),
|
|
|
|
|
2002-08-17 19:08:21 +00:00
|
|
|
# dialogs from libraries
|
2002-04-18 05:43:08 +00:00
|
|
|
('More Dialogs', [
|
|
|
|
'ErrorDialogs',
|
|
|
|
'ImageBrowser',
|
|
|
|
'wxMultipleChoiceDialog',
|
|
|
|
'wxScrolledMessageDialog',
|
|
|
|
]),
|
|
|
|
|
|
|
|
# core controls
|
|
|
|
('Core Windows/Controls', [
|
2003-07-02 23:13:10 +00:00
|
|
|
'PopupMenu',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxButton',
|
|
|
|
'wxCheckBox',
|
|
|
|
'wxCheckListBox',
|
|
|
|
'wxChoice',
|
|
|
|
'wxComboBox',
|
|
|
|
'wxGauge',
|
|
|
|
'wxGenericDirCtrl',
|
|
|
|
'wxGrid',
|
2003-07-02 23:13:10 +00:00
|
|
|
'wxGrid_MegaExample',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxListBox',
|
|
|
|
'wxListCtrl',
|
2002-06-15 05:52:22 +00:00
|
|
|
'wxListCtrl_virtual',
|
2002-07-02 17:08:55 +00:00
|
|
|
'wxMenu',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxNotebook',
|
|
|
|
'wxPopupWindow',
|
|
|
|
'wxRadioBox',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxRadioButton',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxSashWindow',
|
|
|
|
'wxScrolledWindow',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxSlider',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxSpinButton',
|
|
|
|
'wxSpinCtrl',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxSplitterWindow',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxStaticBitmap',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxStaticText',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxStatusBar',
|
|
|
|
'wxTextCtrl',
|
|
|
|
'wxToggleButton',
|
|
|
|
'wxToolBar',
|
|
|
|
'wxTreeCtrl',
|
|
|
|
'wxValidator',
|
|
|
|
]),
|
|
|
|
|
|
|
|
# controls coming from other librairies
|
|
|
|
('More Windows/Controls', [
|
2003-03-25 06:35:27 +00:00
|
|
|
#'wxFloatBar', deprecated
|
|
|
|
#'wxMVCTree', deprecated
|
2003-07-02 23:13:10 +00:00
|
|
|
#'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now.
|
|
|
|
'AnalogClockWindow',
|
2002-04-18 05:43:08 +00:00
|
|
|
'ColourSelect',
|
|
|
|
'ContextHelp',
|
|
|
|
'FancyText',
|
|
|
|
'FileBrowseButton',
|
|
|
|
'GenericButtons',
|
2003-07-02 23:13:10 +00:00
|
|
|
'MaskedEditControls',
|
|
|
|
'PyShell',
|
2002-04-18 05:43:08 +00:00
|
|
|
'PyCrust',
|
|
|
|
'SplitTree',
|
|
|
|
'TablePrint',
|
2003-03-25 06:35:27 +00:00
|
|
|
'Throbber',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxCalendar',
|
|
|
|
'wxCalendarCtrl',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxPyColourChooser',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxDynamicSashWindow',
|
|
|
|
'wxEditableListBox',
|
|
|
|
'wxEditor',
|
|
|
|
'wxHtmlWindow',
|
2002-07-03 22:05:30 +00:00
|
|
|
'wxIEHtmlWin',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxIntCtrl',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxLEDNumberCtrl',
|
|
|
|
'wxMimeTypesManager',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxMultiSash',
|
|
|
|
'wxPopupControl',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxStyledTextCtrl_1',
|
|
|
|
'wxStyledTextCtrl_2',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxTimeCtrl',
|
2003-07-02 23:13:10 +00:00
|
|
|
'wxTreeListCtrl',
|
2003-08-08 21:32:52 +00:00
|
|
|
'wxVListBox',
|
2002-04-18 05:43:08 +00:00
|
|
|
]),
|
|
|
|
|
|
|
|
# How to lay out the controls in a frame/dialog
|
|
|
|
('Window Layout', [
|
|
|
|
'LayoutAnchors',
|
|
|
|
'Layoutf',
|
|
|
|
'RowColSizer',
|
|
|
|
'Sizers',
|
|
|
|
'wxLayoutConstraints',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxScrolledPanel',
|
2002-08-24 02:29:34 +00:00
|
|
|
'wxXmlResource',
|
|
|
|
'wxXmlResourceHandler',
|
2002-04-18 05:43:08 +00:00
|
|
|
]),
|
|
|
|
|
|
|
|
# ditto
|
|
|
|
('Process and Events', [
|
2003-03-25 06:35:27 +00:00
|
|
|
'EventManager',
|
2002-04-18 05:43:08 +00:00
|
|
|
'infoframe',
|
|
|
|
'OOR',
|
|
|
|
'PythonEvents',
|
|
|
|
'Threads',
|
2003-03-25 06:35:27 +00:00
|
|
|
'wxKeyEvents',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxProcess',
|
|
|
|
'wxTimer',
|
|
|
|
]),
|
|
|
|
|
|
|
|
# Clipboard and DnD
|
|
|
|
('Clipboard and DnD', [
|
|
|
|
'CustomDragAndDrop',
|
|
|
|
'DragAndDrop',
|
|
|
|
'URLDragAndDrop',
|
|
|
|
]),
|
|
|
|
|
|
|
|
# Images
|
2003-03-25 06:35:27 +00:00
|
|
|
('Using Images', [
|
|
|
|
'Throbber',
|
|
|
|
'wxArtProvider',
|
2002-04-18 05:43:08 +00:00
|
|
|
'wxDragImage',
|
|
|
|
'wxImage',
|
|
|
|
'wxImageFromStream',
|
|
|
|
'wxMask',
|
|
|
|
]),
|
|
|
|
|
|
|
|
# Other stuff
|
|
|
|
('Miscellaneous', [
|
|
|
|
'ColourDB',
|
|
|
|
'DialogUnits',
|
|
|
|
'DrawXXXList',
|
|
|
|
'FontEnumerator',
|
2003-08-08 21:32:52 +00:00
|
|
|
'NewNamespace',
|
2002-04-18 05:43:08 +00:00
|
|
|
'PrintFramework',
|
2003-08-08 21:32:52 +00:00
|
|
|
'ShapedWindow',
|
2003-03-25 06:35:27 +00:00
|
|
|
'Throbber',
|
2002-04-18 05:43:08 +00:00
|
|
|
'Unicode',
|
|
|
|
'wxFileHistory',
|
|
|
|
'wxJoystick',
|
|
|
|
'wxOGL',
|
|
|
|
'wxWave',
|
|
|
|
]),
|
|
|
|
|
|
|
|
# need libs not coming with the demo
|
|
|
|
('Objects using an external library', [
|
|
|
|
'ActiveXWrapper_Acrobat',
|
|
|
|
'ActiveXWrapper_IE',
|
|
|
|
'wxGLCanvas',
|
|
|
|
'wxPlotCanvas',
|
|
|
|
]),
|
|
|
|
|
2002-07-06 18:13:59 +00:00
|
|
|
|
2002-04-18 05:43:08 +00:00
|
|
|
('Check out the samples dir too', [
|
|
|
|
]),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
class MyLog(wx.PyLog):
|
2001-10-05 18:29:29 +00:00
|
|
|
def __init__(self, textCtrl, logTime=0):
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.PyLog.__init__(self)
|
2001-10-05 18:29:29 +00:00
|
|
|
self.tc = textCtrl
|
|
|
|
self.logTime = logTime
|
|
|
|
|
|
|
|
def DoLogString(self, message, timeStamp):
|
|
|
|
if self.logTime:
|
|
|
|
message = time.strftime("%X", time.localtime(timeStamp)) + \
|
|
|
|
": " + message
|
2003-03-25 06:35:27 +00:00
|
|
|
if self.tc:
|
|
|
|
self.tc.AppendText(message + '\n')
|
2001-10-05 18:29:29 +00:00
|
|
|
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
class MyTP(wx.PyTipProvider):
|
2002-07-21 02:57:38 +00:00
|
|
|
def GetTip(self):
|
|
|
|
return "This is my tip"
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# A class to be used to display source code in the demo. Try using the
|
|
|
|
# wxSTC in the wxStyledTextCtrl_2 sample first, fall back to wxTextCtrl
|
|
|
|
# if there is an error, such as the stc module not being present.
|
|
|
|
|
|
|
|
try:
|
|
|
|
##raise ImportError
|
|
|
|
from wx import stc
|
|
|
|
from wxStyledTextCtrl_2 import PythonSTC
|
|
|
|
class DemoCodeViewer(PythonSTC):
|
|
|
|
def __init__(self, parent, ID):
|
|
|
|
PythonSTC.__init__(self, parent, ID)
|
|
|
|
self.SetEdgeMode(stc.STC_EDGE_NONE)
|
|
|
|
self.SetSelBackground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT))
|
|
|
|
self.SetSelForeground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))
|
|
|
|
|
|
|
|
# Some methods to make it compatible with how the wxTextCtrl is used
|
|
|
|
def SetValue(self, value):
|
|
|
|
self.SetReadOnly(False)
|
|
|
|
self.SetText(value)
|
|
|
|
self.SetReadOnly(True)
|
|
|
|
|
|
|
|
def Clear(self):
|
|
|
|
self.ClearAll()
|
|
|
|
|
|
|
|
def SetInsertionPoint(self, pos):
|
|
|
|
self.SetCurrentPos(pos)
|
|
|
|
|
|
|
|
def ShowPosition(self, pos):
|
|
|
|
self.GotoPos(pos)
|
|
|
|
|
|
|
|
def GetLastPosition(self):
|
|
|
|
return self.GetLength()
|
|
|
|
|
|
|
|
def GetRange(self, start, end):
|
|
|
|
return self.GetTextRange(start, end)
|
|
|
|
|
|
|
|
def GetSelection(self):
|
|
|
|
return self.GetAnchor(), self.GetCurrentPos()
|
|
|
|
|
|
|
|
def SetSelection(self, start, end):
|
|
|
|
self.SetSelectionStart(start)
|
|
|
|
self.SetSelectionEnd(end)
|
|
|
|
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
class DemoCodeViewer(wx.TextCtrl):
|
|
|
|
def __init__(self, parent, ID):
|
|
|
|
wx.TextCtrl.__init__(self, parent, ID, style =
|
|
|
|
wx.TE_MULTILINE | wx.TE_READONLY |
|
|
|
|
wx.HSCROLL | wx.TE_RICH2 | wx.TE_NOHIDESEL)
|
|
|
|
|
|
|
|
|
2002-01-24 01:24:39 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def opj(path):
|
|
|
|
"""Convert paths to the platform-specific separator"""
|
2003-03-25 06:35:27 +00:00
|
|
|
return apply(os.path.join, tuple(path.split('/')))
|
2002-01-24 01:24:39 +00:00
|
|
|
|
|
|
|
|
2001-10-05 18:29:29 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
class wxPythonDemo(wx.Frame):
|
2002-03-18 22:11:23 +00:00
|
|
|
overviewText = "wxPython Overview"
|
2000-10-30 21:08:42 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
def __init__(self, parent, id, title):
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.Frame.__init__(self, parent, -1, title, size = (800, 600),
|
|
|
|
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
|
1999-09-30 07:11:20 +00:00
|
|
|
|
1999-11-25 07:08:14 +00:00
|
|
|
self.cwd = os.getcwd()
|
2000-08-08 06:11:51 +00:00
|
|
|
self.curOverview = ""
|
2003-03-25 06:35:27 +00:00
|
|
|
self.window = None
|
1999-11-25 07:08:14 +00:00
|
|
|
|
2002-02-26 22:35:10 +00:00
|
|
|
icon = images.getMondrianIcon()
|
2001-04-09 19:36:36 +00:00
|
|
|
self.SetIcon(icon)
|
2000-10-30 21:08:42 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
if wx.Platform == '__WXMSW__':
|
2000-10-30 21:08:42 +00:00
|
|
|
# setup a taskbar icon, and catch some events from it
|
2003-07-02 23:13:10 +00:00
|
|
|
self.tbicon = wx.TaskBarIcon()
|
2000-10-30 21:08:42 +00:00
|
|
|
self.tbicon.SetIcon(icon, "wxPython Demo")
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate)
|
|
|
|
wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarMenu)
|
|
|
|
wx.EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
|
|
|
|
wx.EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
|
2000-10-30 21:08:42 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.CallAfter(self.ShowTip)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
self.otherWin = None
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EVT_IDLE(self, self.OnIdle)
|
|
|
|
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
|
|
|
wx.EVT_ICONIZE(self, self.OnIconfiy)
|
|
|
|
wx.EVT_MAXIMIZE(self, self.OnMaximize)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
self.Centre(wx.BOTH)
|
|
|
|
self.CreateStatusBar(1, wx.ST_SIZEGRIP)
|
1999-10-16 06:08:16 +00:00
|
|
|
|
2003-08-14 03:58:15 +00:00
|
|
|
splitter = wx.SplitterWindow(self, -1)
|
|
|
|
splitter2 = wx.SplitterWindow(splitter, -1)
|
1999-10-16 06:08:16 +00:00
|
|
|
|
2001-06-15 21:43:26 +00:00
|
|
|
def EmptyHandler(evt): pass
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EVT_ERASE_BACKGROUND(splitter, EmptyHandler)
|
|
|
|
wx.EVT_ERASE_BACKGROUND(splitter2, EmptyHandler)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
# Prevent TreeCtrl from displaying all items after destruction when True
|
|
|
|
self.dying = False
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
# Make a File menu
|
2003-07-02 23:13:10 +00:00
|
|
|
self.mainmenu = wx.MenuBar()
|
|
|
|
menu = wx.Menu()
|
|
|
|
exitID = wx.NewId()
|
1999-10-06 06:22:25 +00:00
|
|
|
menu.Append(exitID, 'E&xit\tAlt-X', 'Get the heck outta here!')
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EVT_MENU(self, exitID, self.OnFileExit)
|
|
|
|
wx.App_SetMacExitMenuItemId(exitID)
|
1999-04-30 03:29:54 +00:00
|
|
|
self.mainmenu.Append(menu, '&File')
|
|
|
|
|
1999-09-13 19:31:50 +00:00
|
|
|
# Make a Demo menu
|
2003-07-02 23:13:10 +00:00
|
|
|
menu = wx.Menu()
|
1999-09-13 19:31:50 +00:00
|
|
|
for item in _treeList:
|
2003-07-02 23:13:10 +00:00
|
|
|
submenu = wx.Menu()
|
1999-09-13 19:31:50 +00:00
|
|
|
for childItem in item[1]:
|
2003-07-02 23:13:10 +00:00
|
|
|
mID = wx.NewId()
|
1999-09-13 19:31:50 +00:00
|
|
|
submenu.Append(mID, childItem)
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EVT_MENU(self, mID, self.OnDemoMenu)
|
|
|
|
menu.AppendMenu(wx.NewId(), item[0], submenu)
|
1999-09-13 19:31:50 +00:00
|
|
|
self.mainmenu.Append(menu, '&Demo')
|
|
|
|
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
# Make a Help menu
|
2003-07-02 23:13:10 +00:00
|
|
|
helpID = wx.NewId()
|
|
|
|
findID = wx.NewId()
|
|
|
|
findnextID = wx.NewId()
|
|
|
|
menu = wx.Menu()
|
2003-03-25 06:35:27 +00:00
|
|
|
menu.Append(findID, '&Find\tCtrl-F', 'Find in the Demo Code')
|
|
|
|
menu.Append(findnextID, 'Find &Next\tF3', 'Find Next')
|
|
|
|
menu.AppendSeparator()
|
1999-09-30 07:11:20 +00:00
|
|
|
menu.Append(helpID, '&About\tCtrl-H', 'wxPython RULES!!!')
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.App_SetMacAboutMenuItemId(helpID)
|
|
|
|
wx.EVT_MENU(self, helpID, self.OnHelpAbout)
|
|
|
|
wx.EVT_MENU(self, findID, self.OnHelpFind)
|
|
|
|
wx.EVT_MENU(self, findnextID, self.OnFindNext)
|
|
|
|
wx.EVT_COMMAND_FIND(self, -1, self.OnFind)
|
|
|
|
wx.EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind)
|
|
|
|
wx.EVT_COMMAND_FIND_CLOSE(self, -1 , self.OnFindClose)
|
1999-04-30 03:29:54 +00:00
|
|
|
self.mainmenu.Append(menu, '&Help')
|
|
|
|
self.SetMenuBar(self.mainmenu)
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
self.finddata = wx.FindReplaceData()
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
if 0:
|
|
|
|
# This is another way to set Accelerators, in addition to
|
|
|
|
# using the '\t<key>' syntax in the menu items.
|
2003-07-02 23:13:10 +00:00
|
|
|
aTable = wx.AcceleratorTable([(wx.ACCEL_ALT, ord('X'), exitID),
|
|
|
|
(wx.ACCEL_CTRL, ord('H'), helpID),
|
|
|
|
(wx.ACCEL_CTRL, ord('F'), findID),
|
|
|
|
(wx.ACCEL_NORMAL, WXK_F3, findnextID)
|
|
|
|
])
|
2003-03-25 06:35:27 +00:00
|
|
|
self.SetAcceleratorTable(aTable)
|
1999-09-30 07:11:20 +00:00
|
|
|
|
1999-06-22 07:03:29 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
# Create a TreeCtrl
|
2003-07-02 23:13:10 +00:00
|
|
|
tID = wx.NewId()
|
2000-07-15 19:51:35 +00:00
|
|
|
self.treeMap = {}
|
2003-08-08 21:32:52 +00:00
|
|
|
self.tree = wx.TreeCtrl(splitter, tID, style =
|
|
|
|
wx.TR_DEFAULT_STYLE #| wx.TR_HAS_VARIABLE_ROW_HEIGHT
|
2002-08-13 23:59:08 +00:00
|
|
|
)
|
2002-02-26 22:35:10 +00:00
|
|
|
|
2002-03-18 22:11:23 +00:00
|
|
|
root = self.tree.AddRoot("wxPython Overview")
|
2000-07-15 19:51:35 +00:00
|
|
|
firstChild = None
|
|
|
|
for item in _treeList:
|
|
|
|
child = self.tree.AppendItem(root, item[0])
|
|
|
|
if not firstChild: firstChild = child
|
|
|
|
for childItem in item[1]:
|
|
|
|
theDemo = self.tree.AppendItem(child, childItem)
|
|
|
|
self.treeMap[childItem] = theDemo
|
|
|
|
|
|
|
|
self.tree.Expand(root)
|
|
|
|
self.tree.Expand(firstChild)
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded)
|
|
|
|
wx.EVT_TREE_ITEM_COLLAPSED (self.tree, tID, self.OnItemCollapsed)
|
|
|
|
wx.EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged)
|
|
|
|
wx.EVT_LEFT_DOWN (self.tree, self.OnTreeLeftDown)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
# Create a Notebook
|
2003-07-02 23:13:10 +00:00
|
|
|
self.nb = wx.Notebook(splitter2, -1, style=wx.CLIP_CHILDREN)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
# Set up a wx.html.HtmlWindow on the Overview Notebook page
|
2002-04-29 23:09:48 +00:00
|
|
|
# we put it in a panel first because there seems to be a
|
|
|
|
# refresh bug of some sort (wxGTK) when it is directly in
|
|
|
|
# the notebook...
|
|
|
|
if 0: # the old way
|
2003-07-02 23:13:10 +00:00
|
|
|
self.ovr = wx.html.HtmlWindow(self.nb, -1, size=(400, 400))
|
2002-04-29 23:09:48 +00:00
|
|
|
self.nb.AddPage(self.ovr, self.overviewText)
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
else: # hopefully I can remove this hacky code soon, see SF bug #216861
|
|
|
|
panel = wx.Panel(self.nb, -1, style=wx.CLIP_CHILDREN)
|
|
|
|
self.ovr = wx.html.HtmlWindow(panel, -1, size=(400, 400))
|
2002-04-29 23:09:48 +00:00
|
|
|
self.nb.AddPage(panel, self.overviewText)
|
|
|
|
|
|
|
|
def OnOvrSize(evt, ovr=self.ovr):
|
|
|
|
ovr.SetSize(evt.GetSize())
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EVT_SIZE(panel, OnOvrSize)
|
|
|
|
wx.EVT_ERASE_BACKGROUND(panel, EmptyHandler)
|
2002-04-29 23:09:48 +00:00
|
|
|
|
2000-10-30 21:08:42 +00:00
|
|
|
|
2002-03-18 22:11:23 +00:00
|
|
|
self.SetOverview(self.overviewText, overview)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
# Set up a notebook page for viewing the source code of each sample
|
|
|
|
self.txt = DemoCodeViewer(self.nb, -1)
|
1999-04-30 03:29:54 +00:00
|
|
|
self.nb.AddPage(self.txt, "Demo Code")
|
2003-07-02 23:13:10 +00:00
|
|
|
self.GetDemoFile('Main.py')
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Set up a log on the View Log Notebook page
|
2003-07-02 23:13:10 +00:00
|
|
|
self.log = wx.TextCtrl(splitter2, -1,
|
|
|
|
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
|
2002-04-01 20:28:01 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
# Set the wxWindows log target to be this textctrl
|
2003-07-02 23:13:10 +00:00
|
|
|
#wx.Log_SetActiveTarget(wx.LogTextCtrl(self.log))
|
2002-04-01 20:28:01 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
# But instead of the above we want to show how to use our own wx.Log class
|
|
|
|
wx.Log_SetActiveTarget(MyLog(self.log))
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2002-06-26 20:08:30 +00:00
|
|
|
# for serious debugging
|
2003-07-02 23:13:10 +00:00
|
|
|
#wx.Log_SetActiveTarget(wx.LogStderr())
|
|
|
|
#wx.Log_SetTraceMask(wx.TraceMessages)
|
1999-10-16 06:08:16 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
self.Show(True)
|
1999-10-16 06:08:16 +00:00
|
|
|
|
2002-06-26 20:08:30 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
# add the windows to the splitter and split it.
|
2003-03-25 06:35:27 +00:00
|
|
|
splitter2.SplitHorizontally(self.nb, self.log, 450)
|
|
|
|
splitter.SplitVertically(self.tree, splitter2, 180)
|
2002-02-26 22:35:10 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
splitter.SetMinimumPaneSize(20)
|
2002-02-26 22:35:10 +00:00
|
|
|
splitter2.SetMinimumPaneSize(20)
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
1999-06-22 07:03:29 +00:00
|
|
|
# select initial items
|
|
|
|
self.nb.SetSelection(0)
|
2000-07-15 19:51:35 +00:00
|
|
|
self.tree.SelectItem(root)
|
1999-09-13 19:31:50 +00:00
|
|
|
|
|
|
|
if len(sys.argv) == 2:
|
|
|
|
try:
|
|
|
|
selectedDemo = self.treeMap[sys.argv[1]]
|
|
|
|
except:
|
|
|
|
selectedDemo = None
|
2000-07-15 19:51:35 +00:00
|
|
|
if selectedDemo:
|
1999-09-13 19:31:50 +00:00
|
|
|
self.tree.SelectItem(selectedDemo)
|
|
|
|
self.tree.EnsureVisible(selectedDemo)
|
|
|
|
|
1999-06-22 07:03:29 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.LogMessage('window handle: %s' % self.GetHandle())
|
1999-10-29 22:25:04 +00:00
|
|
|
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#---------------------------------------------
|
|
|
|
def WriteText(self, text):
|
2000-07-15 19:51:35 +00:00
|
|
|
if text[-1:] == '\n':
|
|
|
|
text = text[:-1]
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.LogMessage(text)
|
2000-07-15 19:51:35 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
def write(self, txt):
|
|
|
|
self.WriteText(txt)
|
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnItemExpanded(self, event):
|
|
|
|
item = event.GetItem()
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.LogMessage("OnItemExpanded: %s" % self.tree.GetItemText(item))
|
2000-10-30 21:08:42 +00:00
|
|
|
event.Skip()
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnItemCollapsed(self, event):
|
|
|
|
item = event.GetItem()
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.LogMessage("OnItemCollapsed: %s" % self.tree.GetItemText(item))
|
2000-10-30 21:08:42 +00:00
|
|
|
event.Skip()
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnTreeLeftDown(self, event):
|
|
|
|
pt = event.GetPosition();
|
|
|
|
item, flags = self.tree.HitTest(pt)
|
|
|
|
if item == self.tree.GetSelection():
|
2002-04-19 20:12:19 +00:00
|
|
|
self.SetOverview(self.tree.GetItemText(item)+" Overview", self.curOverview)
|
2000-11-21 03:44:14 +00:00
|
|
|
event.Skip()
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnSelChanged(self, event):
|
|
|
|
if self.dying:
|
|
|
|
return
|
|
|
|
|
1999-10-16 06:08:16 +00:00
|
|
|
item = event.GetItem()
|
|
|
|
itemText = self.tree.GetItemText(item)
|
|
|
|
self.RunDemo(itemText)
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def RunDemo(self, itemText):
|
1999-11-25 07:08:14 +00:00
|
|
|
os.chdir(self.cwd)
|
1999-04-30 03:29:54 +00:00
|
|
|
if self.nb.GetPageCount() == 3:
|
|
|
|
if self.nb.GetSelection() == 2:
|
|
|
|
self.nb.SetSelection(0)
|
2003-03-25 06:35:27 +00:00
|
|
|
# inform the window that it's time to quit if it cares
|
|
|
|
if self.window is not None:
|
|
|
|
if hasattr(self.window, "ShutdownDemo"):
|
|
|
|
self.window.ShutdownDemo()
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.SafeYield() # in case the page has pending events
|
1999-04-30 03:29:54 +00:00
|
|
|
self.nb.DeletePage(2)
|
|
|
|
|
2002-03-18 22:11:23 +00:00
|
|
|
if itemText == self.overviewText:
|
1999-04-30 03:29:54 +00:00
|
|
|
self.GetDemoFile('Main.py')
|
2002-03-18 22:11:23 +00:00
|
|
|
self.SetOverview(self.overviewText, overview)
|
1999-04-30 03:29:54 +00:00
|
|
|
self.nb.Refresh();
|
1999-09-10 06:25:47 +00:00
|
|
|
self.window = None
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
if os.path.exists(itemText + '.py'):
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.BeginBusyCursor()
|
|
|
|
wx.LogMessage("Running demo %s.py..." % itemText)
|
2000-07-15 19:51:35 +00:00
|
|
|
try:
|
|
|
|
self.GetDemoFile(itemText + '.py')
|
|
|
|
module = __import__(itemText, globals())
|
2002-03-18 22:11:23 +00:00
|
|
|
self.SetOverview(itemText + " Overview", module.overview)
|
2000-07-15 19:51:35 +00:00
|
|
|
finally:
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.EndBusyCursor()
|
2002-05-17 06:01:44 +00:00
|
|
|
self.tree.Refresh()
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
# in case runTest is modal, make sure things look right...
|
|
|
|
self.nb.Refresh();
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.SafeYield()
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
self.window = module.runTest(self, self.nb, self) ###
|
2003-03-25 06:35:27 +00:00
|
|
|
if self.window is not None:
|
1999-09-10 06:25:47 +00:00
|
|
|
self.nb.AddPage(self.window, 'Demo')
|
1999-04-30 03:29:54 +00:00
|
|
|
self.nb.SetSelection(2)
|
2002-04-30 02:49:37 +00:00
|
|
|
self.nb.Refresh() # without this wxMac has troubles showing the just added page
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
else:
|
2000-07-15 19:51:35 +00:00
|
|
|
self.ovr.SetPage("")
|
1999-04-30 03:29:54 +00:00
|
|
|
self.txt.Clear()
|
1999-09-10 06:25:47 +00:00
|
|
|
self.window = None
|
1999-04-30 03:29:54 +00:00
|
|
|
|
1999-09-30 07:11:20 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
# Get the Demo files
|
|
|
|
def GetDemoFile(self, filename):
|
|
|
|
self.txt.Clear()
|
1999-06-22 07:03:29 +00:00
|
|
|
try:
|
|
|
|
self.txt.SetValue(open(filename).read())
|
1999-07-31 07:56:15 +00:00
|
|
|
except IOError:
|
2003-07-02 23:13:10 +00:00
|
|
|
self.txt.SetValue("Cannot open %s file." % filename)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
self.txt.SetInsertionPoint(0)
|
|
|
|
self.txt.ShowPosition(0)
|
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def SetOverview(self, name, text):
|
2000-07-15 19:51:35 +00:00
|
|
|
self.curOverview = text
|
|
|
|
lead = text[:6]
|
|
|
|
if lead != '<html>' and lead != '<HTML>':
|
2003-03-25 06:35:27 +00:00
|
|
|
text = '<br>'.join(text.split('\n'))
|
2000-07-15 19:51:35 +00:00
|
|
|
self.ovr.SetPage(text)
|
1999-04-30 03:29:54 +00:00
|
|
|
self.nb.SetPageText(0, name)
|
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
# Menu methods
|
2000-10-30 21:08:42 +00:00
|
|
|
def OnFileExit(self, *event):
|
1999-04-30 03:29:54 +00:00
|
|
|
self.Close()
|
|
|
|
|
|
|
|
def OnHelpAbout(self, event):
|
1999-09-17 05:55:00 +00:00
|
|
|
from About import MyAboutBox
|
1999-09-13 19:31:50 +00:00
|
|
|
about = MyAboutBox(self)
|
1999-04-30 03:29:54 +00:00
|
|
|
about.ShowModal()
|
|
|
|
about.Destroy()
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
def OnHelpFind(self, event):
|
|
|
|
self.nb.SetSelection(1)
|
2003-07-02 23:13:10 +00:00
|
|
|
self.finddlg = wx.FindReplaceDialog(self, self.finddata, "Find",
|
|
|
|
wx.FR_NOUPDOWN |
|
|
|
|
wx.FR_NOMATCHCASE |
|
|
|
|
wx.FR_NOWHOLEWORD)
|
2003-03-25 06:35:27 +00:00
|
|
|
self.finddlg.Show(True)
|
|
|
|
|
|
|
|
def OnFind(self, event):
|
|
|
|
self.nb.SetSelection(1)
|
|
|
|
end = self.txt.GetLastPosition()
|
|
|
|
textstring = self.txt.GetRange(0, end).lower()
|
|
|
|
start = self.txt.GetSelection()[1]
|
|
|
|
findstring = self.finddata.GetFindString().lower()
|
|
|
|
loc = textstring.find(findstring, start)
|
|
|
|
if loc == -1 and start != 0:
|
|
|
|
# string not found, start at beginning
|
|
|
|
start = 0
|
|
|
|
loc = textstring.find(findstring, start)
|
|
|
|
if loc == -1:
|
2003-07-02 23:13:10 +00:00
|
|
|
dlg = wx.MessageDialog(self, 'Find String Not Found',
|
2003-03-25 06:35:27 +00:00
|
|
|
'Find String Not Found in Demo File',
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.OK | wx.ICON_INFORMATION)
|
2003-03-25 06:35:27 +00:00
|
|
|
dlg.ShowModal()
|
|
|
|
dlg.Destroy()
|
|
|
|
if self.finddlg:
|
|
|
|
if loc == -1:
|
|
|
|
self.finddlg.SetFocus()
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.finddlg.Destroy()
|
|
|
|
self.txt.ShowPosition(loc)
|
2003-07-02 23:13:10 +00:00
|
|
|
self.txt.SetSelection(loc, loc + len(findstring))
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def OnFindNext(self, event):
|
|
|
|
if self.finddata.GetFindString():
|
|
|
|
self.OnFind(event)
|
|
|
|
else:
|
|
|
|
self.OnHelpFind(event)
|
|
|
|
|
|
|
|
def OnFindClose(self, event):
|
|
|
|
event.GetDialog().Destroy()
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnCloseWindow(self, event):
|
2003-03-25 06:35:27 +00:00
|
|
|
self.dying = True
|
1999-09-10 06:25:47 +00:00
|
|
|
self.window = None
|
1999-09-18 18:21:02 +00:00
|
|
|
self.mainmenu = None
|
2000-10-30 21:08:42 +00:00
|
|
|
if hasattr(self, "tbicon"):
|
|
|
|
del self.tbicon
|
1999-04-30 03:29:54 +00:00
|
|
|
self.Destroy()
|
|
|
|
|
2000-10-30 21:08:42 +00:00
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#---------------------------------------------
|
|
|
|
def OnIdle(self, event):
|
|
|
|
if self.otherWin:
|
|
|
|
self.otherWin.Raise()
|
1999-09-10 06:25:47 +00:00
|
|
|
self.window = self.otherWin
|
1999-04-30 03:29:54 +00:00
|
|
|
self.otherWin = None
|
|
|
|
|
2002-03-20 20:48:16 +00:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def ShowTip(self):
|
|
|
|
try:
|
|
|
|
showTipText = open(opj("data/showTips")).read()
|
|
|
|
showTip, index = eval(showTipText)
|
|
|
|
except IOError:
|
|
|
|
showTip, index = (1, 0)
|
|
|
|
if showTip:
|
2003-07-02 23:13:10 +00:00
|
|
|
tp = wx.CreateFileTipProvider(opj("data/tips.txt"), index)
|
2002-07-21 02:57:38 +00:00
|
|
|
##tp = MyTP(0)
|
2003-07-02 23:13:10 +00:00
|
|
|
showTip = wx.ShowTip(self, tp)
|
2002-03-20 20:48:16 +00:00
|
|
|
index = tp.GetCurrentTip()
|
|
|
|
open(opj("data/showTips"), "w").write(str( (showTip, index) ))
|
|
|
|
|
|
|
|
|
1999-09-13 19:31:50 +00:00
|
|
|
#---------------------------------------------
|
|
|
|
def OnDemoMenu(self, event):
|
2000-07-15 19:51:35 +00:00
|
|
|
try:
|
|
|
|
selectedDemo = self.treeMap[self.mainmenu.GetLabel(event.GetId())]
|
|
|
|
except:
|
|
|
|
selectedDemo = None
|
|
|
|
if selectedDemo:
|
|
|
|
self.tree.SelectItem(selectedDemo)
|
|
|
|
self.tree.EnsureVisible(selectedDemo)
|
1999-09-13 19:31:50 +00:00
|
|
|
|
2000-10-30 21:08:42 +00:00
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnTaskBarActivate(self, evt):
|
|
|
|
if self.IsIconized():
|
2003-03-25 06:35:27 +00:00
|
|
|
self.Iconize(False)
|
2000-10-30 21:08:42 +00:00
|
|
|
if not self.IsShown():
|
2003-03-25 06:35:27 +00:00
|
|
|
self.Show(True)
|
2000-10-30 21:08:42 +00:00
|
|
|
self.Raise()
|
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
|
|
|
|
TBMENU_RESTORE = 1000
|
|
|
|
TBMENU_CLOSE = 1001
|
|
|
|
|
|
|
|
def OnTaskBarMenu(self, evt):
|
2003-07-02 23:13:10 +00:00
|
|
|
menu = wx.Menu()
|
2000-10-30 21:08:42 +00:00
|
|
|
menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo")
|
|
|
|
menu.Append(self.TBMENU_CLOSE, "Close")
|
|
|
|
self.tbicon.PopupMenu(menu)
|
|
|
|
menu.Destroy()
|
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnTaskBarClose(self, evt):
|
|
|
|
self.Close()
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
# because of the way wx.TaskBarIcon.PopupMenu is implemented we have to
|
2000-10-30 21:08:42 +00:00
|
|
|
# prod the main idle handler a bit to get the window to actually close
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.GetApp().ProcessIdle()
|
2000-10-30 21:08:42 +00:00
|
|
|
|
|
|
|
|
2001-04-02 03:49:52 +00:00
|
|
|
#---------------------------------------------
|
|
|
|
def OnIconfiy(self, evt):
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.LogMessage("OnIconfiy")
|
2001-04-02 03:49:52 +00:00
|
|
|
evt.Skip()
|
|
|
|
|
|
|
|
#---------------------------------------------
|
|
|
|
def OnMaximize(self, evt):
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.LogMessage("OnMaximize")
|
2001-04-02 03:49:52 +00:00
|
|
|
evt.Skip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
class MySplashScreen(wx.SplashScreen):
|
2002-01-05 23:45:33 +00:00
|
|
|
def __init__(self):
|
2003-07-02 23:13:10 +00:00
|
|
|
bmp = wx.Image(opj("bitmaps/splash.gif")).ConvertToBitmap()
|
|
|
|
wx.SplashScreen.__init__(self, bmp,
|
|
|
|
wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,
|
2002-05-27 18:39:46 +00:00
|
|
|
4000, None, -1,
|
2003-07-02 23:13:10 +00:00
|
|
|
style = wx.SIMPLE_BORDER|wx.FRAME_NO_TASKBAR|wx.STAY_ON_TOP)
|
|
|
|
wx.EVT_CLOSE(self, self.OnClose)
|
2002-01-05 23:45:33 +00:00
|
|
|
|
|
|
|
def OnClose(self, evt):
|
1999-11-20 21:15:12 +00:00
|
|
|
frame = wxPythonDemo(None, -1, "wxPython: (A Demonstration)")
|
2003-03-25 06:35:27 +00:00
|
|
|
frame.Show()
|
2002-03-20 20:48:16 +00:00
|
|
|
evt.Skip() # Make sure the default handler runs too...
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2002-01-05 23:45:33 +00:00
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
class MyApp(wx.App):
|
2002-01-05 23:45:33 +00:00
|
|
|
def OnInit(self):
|
|
|
|
"""
|
2002-01-15 04:54:19 +00:00
|
|
|
Create and show the splash screen. It will then create and show
|
2002-01-05 23:45:33 +00:00
|
|
|
the main frame when it is time to do so.
|
|
|
|
"""
|
2003-03-25 06:35:27 +00:00
|
|
|
|
|
|
|
#import locale
|
2003-07-02 23:13:10 +00:00
|
|
|
#self.locale = wx.Locale(wx.LANGUAGE_FRENCH)
|
2003-03-25 06:35:27 +00:00
|
|
|
#locale.setlocale(locale.LC_ALL, 'fr')
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
wx.InitAllImageHandlers()
|
2002-01-05 23:45:33 +00:00
|
|
|
splash = MySplashScreen()
|
|
|
|
splash.Show()
|
2003-03-25 06:35:27 +00:00
|
|
|
return True
|
2002-01-05 23:45:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def main():
|
2000-02-01 21:36:20 +00:00
|
|
|
try:
|
2001-06-15 21:43:26 +00:00
|
|
|
demoPath = os.path.dirname(__file__)
|
2000-02-01 21:36:20 +00:00
|
|
|
os.chdir(demoPath)
|
|
|
|
except:
|
|
|
|
pass
|
2003-07-02 23:13:10 +00:00
|
|
|
app = MyApp(wx.Platform == "__WXMAC__")
|
1999-04-30 03:29:54 +00:00
|
|
|
app.MainLoop()
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
overview = """<html><body>
|
2003-07-02 23:13:10 +00:00
|
|
|
<h2>wxPython</h2>
|
|
|
|
|
|
|
|
<p> wxPython is a <b>GUI toolkit</b> for the <a
|
|
|
|
href="http://www.python.org/">Python</a> programming language. It
|
|
|
|
allows Python programmers to create programs with a robust, highly
|
|
|
|
functional graphical user interface, simply and easily. It is
|
|
|
|
implemented as a Python extension module (native code) that wraps the
|
|
|
|
popular <a href="http://wxwindows.org/front.htm">wxWindows</a> cross
|
|
|
|
platform GUI library, which is written in C++.
|
|
|
|
|
|
|
|
<p> Like Python and wxWindows, wxPython is <b>Open Source</b> which
|
|
|
|
means that it is free for anyone to use and the source code is
|
|
|
|
available for anyone to look at and modify. Or anyone can contribute
|
|
|
|
fixes or enhnacments to the project.
|
|
|
|
|
|
|
|
<p> wxPython is a <b>cross-platform</b> toolkit. This means that the
|
|
|
|
same program will run on multiple platforms without modification.
|
|
|
|
Currently supported platforms are 32-bit Microsoft Windows, most Unix
|
|
|
|
or unix-like systems, and Macintosh OS X. Since the language is
|
|
|
|
Python, wxPython programs are <b>simple, easy</b> to write and easy to
|
|
|
|
understand.
|
|
|
|
|
|
|
|
<p> <b>This demo</b> is not only a collection of test cases for
|
|
|
|
wxPython, but is also designed to help you learn about and how to use
|
|
|
|
wxPython. Each sample is listed in the tree control on the left.
|
|
|
|
When a sample is selected in the tree then a module is loaded and run
|
|
|
|
(usually in a tab of this notebook,) and the source code of the module
|
|
|
|
is loaded in another tab for you to browse and learn from.
|
|
|
|
|
|
|
|
"""
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|