X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b4f1aaad5db4fc94a19d5aef92c45b33ccbf5f18..521808ff62a4e48c88f6853048d9d1befcb18c23:/wxPython/demo/Main.py?ds=sidebyside
diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py
index 76377ae3c1..7dfe9cb2f7 100644
--- a/wxPython/demo/Main.py
+++ b/wxPython/demo/Main.py
@@ -20,7 +20,9 @@ import images
# For debugging
##wx.Trap();
-##print os.getpid(); raw_input("Press a key...")
+##print "wx.VERSION_STRING = ", wx.VERSION_STRING
+##print os.getpid();
+##raw_input("Press Enter...")
#---------------------------------------------------------------------------
@@ -28,15 +30,9 @@ import images
_treeList = [
# new stuff
- ('Recent Additions', [
- 'VListBox',
- 'Listbook',
- 'MaskedNumCtrl',
+ ('Recent Additions/Updates', [
+ 'OGL',
'FloatCanvas',
- 'XmlResourceSubclass',
- 'GridBagSizer',
- 'Cursor',
- 'PyPlot',
]),
# managed windows == things with a (optional) caption you can close
@@ -66,7 +62,6 @@ _treeList = [
# dialogs from libraries
('More Dialogs', [
- 'ErrorDialogs',
'ImageBrowser',
'MultipleChoiceDialog',
'ScrolledMessageDialog',
@@ -74,6 +69,7 @@ _treeList = [
# core controls
('Core Windows/Controls', [
+ 'BitmapButton',
'Button',
'CheckBox',
'CheckListBox',
@@ -123,6 +119,9 @@ _treeList = [
# controls coming from other libraries
('More Windows/Controls', [
+ 'ActiveX_FlashWindow',
+ 'ActiveX_IEHtmlWindow',
+ 'ActiveX_PDFWindow',
#'RightTextCtrl', deprecated as we have wxTE_RIGHT now.
'Calendar',
'CalendarCtrl',
@@ -134,7 +133,6 @@ _treeList = [
'FloatBar',
'FloatCanvas',
'HtmlWindow',
- 'IEHtmlWin',
'IntCtrl',
'MVCTree',
'MaskedEditControls',
@@ -171,7 +169,6 @@ _treeList = [
('Process and Events', [
'EventManager',
'KeyEvents',
- 'OOR',
'Process',
'PythonEvents',
'Threads',
@@ -192,6 +189,7 @@ _treeList = [
'Cursor',
'DragImage',
'Image',
+ 'ImageAlpha',
'ImageFromStream',
'Mask',
'Throbber',
@@ -205,7 +203,6 @@ _treeList = [
'FileHistory',
'FontEnumerator',
'Joystick',
- 'NewNamespace',
'OGL',
'PrintFramework',
'ShapedWindow',
@@ -214,11 +211,8 @@ _treeList = [
]),
# need libs not coming with the demo
- ('Objects using an external library', [
- 'ActiveXWrapper_Acrobat',
- 'ActiveXWrapper_IE',
+ ('Samples using an external library', [
'GLCanvas',
- #'PlotCanvas', # deprecated, use PyPlot
]),
@@ -257,16 +251,18 @@ class MyTP(wx.PyTipProvider):
#
try:
- ##raise ImportError
+ ##raise ImportError # for testing the alternate implementation
from wx import stc
from StyledTextCtrl_2 import PythonSTC
class DemoCodeViewer(PythonSTC):
def __init__(self, parent, ID):
- PythonSTC.__init__(self, parent, ID)
+ PythonSTC.__init__(self, parent, ID, wx.BORDER_NONE)
self.SetUpEditor()
# Some methods to make it compatible with how the wxTextCtrl is used
def SetValue(self, value):
+ if wx.USE_UNICODE:
+ value = value.decode('iso8859_1')
self.SetReadOnly(False)
self.SetText(value)
self.SetReadOnly(True)
@@ -430,6 +426,7 @@ class wxPythonDemo(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, -1, title, size = (800, 600),
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
+
self.cwd = os.getcwd()
self.curOverview = ""
@@ -440,8 +437,11 @@ class wxPythonDemo(wx.Frame):
if wx.Platform != '__WXMAC__':
# setup a taskbar icon, and catch some events from it
+ dim = 16 # (may want to use 22 on wxGTK...)
icon = wx.IconFromBitmap(
- images.getMondrianImage().Scale(16,16).ConvertToBitmap() )
+ images.getMondrianImage().Scale(dim,dim).ConvertToBitmap() )
+ #icon = wx.Icon('bmp_source/mondrian.ico', wx.BITMAP_TYPE_ICO)
+ #icon = images.getMondrianIcon()
self.tbicon = wx.TaskBarIcon()
self.tbicon.SetIcon(icon, "wxPython Demo")
self.tbicon.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarActivate)
@@ -460,13 +460,13 @@ class wxPythonDemo(wx.Frame):
self.Centre(wx.BOTH)
self.CreateStatusBar(1, wx.ST_SIZEGRIP)
- splitter = wx.SplitterWindow(self, -1)
- splitter2 = wx.SplitterWindow(splitter, -1)
+ splitter = wx.SplitterWindow(self, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
+ splitter2 = wx.SplitterWindow(splitter, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
# Set up a log on the View Log Notebook page
self.log = wx.TextCtrl(splitter2, -1,
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
-
+
# Set the wxWindows log target to be this textctrl
#wx.Log_SetActiveTarget(wx.LogTextCtrl(self.log))
@@ -489,9 +489,15 @@ class wxPythonDemo(wx.Frame):
# Make a File menu
self.mainmenu = wx.MenuBar()
menu = wx.Menu()
+ item = menu.Append(-1, '&Redirect Output',
+ 'Redirect print statements to a window',
+ wx.ITEM_CHECK)
+ self.Bind(wx.EVT_MENU, self.OnToggleRedirect, item)
+
item = menu.Append(-1, 'E&xit\tAlt-X', 'Get the heck outta here!')
self.Bind(wx.EVT_MENU, self.OnFileExit, item)
wx.App_SetMacExitMenuItemId(item.GetId())
+
self.mainmenu.Append(menu, '&File')
# Make a Demo menu
@@ -624,7 +630,7 @@ class wxPythonDemo(wx.Frame):
self.tree.EnsureVisible(selectedDemo)
- wx.LogMessage('window handle: %s' % self.GetHandle())
+## wx.LogMessage('window handle: %s' % self.GetHandle())
#---------------------------------------------
@@ -683,7 +689,6 @@ class wxPythonDemo(wx.Frame):
if itemText == self.overviewText:
self.LoadDemoSource('Main.py')
self.SetOverview(self.overviewText, overview)
- self.nb.Refresh();
self.window = None
else:
@@ -702,21 +707,17 @@ class wxPythonDemo(wx.Frame):
wx.EndBusyCursor()
self.tree.Refresh()
- # in case runTest is modal, make sure things look right...
- self.nb.Refresh();
- wx.SafeYield()
-
self.window = module.runTest(self, self.nb, self) ###
if self.window is not None:
self.nb.AddPage(self.window, 'Demo')
self.nb.SetSelection(2)
- self.nb.Refresh() # without this wxMac has troubles showing the just added page
else:
self.ovr.SetPage("")
self.txt.Clear()
self.window = None
+ self.tree.SetFocus()
#---------------------------------------------
@@ -737,6 +738,8 @@ class wxPythonDemo(wx.Frame):
lead = text[:6]
if lead != '' and lead != '':
text = '
'.join(text.split('\n'))
+ if wx.USE_UNICODE:
+ text = text.decode('iso8859_1')
self.ovr.SetPage(text)
self.nb.SetPageText(0, name)
@@ -745,6 +748,15 @@ class wxPythonDemo(wx.Frame):
def OnFileExit(self, *event):
self.Close()
+ def OnToggleRedirect(self, event):
+ app = wx.GetApp()
+ if event.Checked():
+ app.RedirectStdio()
+ print "Print statements and other standard output will now be directed to this window."
+ else:
+ app.RestoreStdio()
+ print "Print statements and other standard output will now be sent to the usual location."
+
def OnHelpAbout(self, event):
from About import MyAboutBox
about = MyAboutBox(self)
@@ -802,8 +814,6 @@ class wxPythonDemo(wx.Frame):
self.dying = True
self.window = None
self.mainmenu = None
- if hasattr(self, "tbicon"):
- del self.tbicon
self.Destroy()
@@ -895,6 +905,7 @@ class MySplashScreen(wx.SplashScreen):
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, evt):
+ self.Hide()
frame = wxPythonDemo(None, -1, "wxPython: (A Demonstration)")
frame.Show()
evt.Skip() # Make sure the default handler runs too...
@@ -907,14 +918,12 @@ class MyApp(wx.App):
the main frame when it is time to do so.
"""
- wx.InitAllImageHandlers()
-
# Normally when using a SplashScreen you would create it, show
# it and then continue on with the applicaiton's
# initialization, finally creating and showing the main
# application window(s). In this case we have nothing else to
# do so we'll delay showing the main frame until later (see
- # OnClose above) so the users can see the SplashScrren effect.
+ # OnClose above) so the users can see the SplashScreen effect.
splash = MySplashScreen()
splash.Show()
@@ -930,7 +939,7 @@ def main():
os.chdir(demoPath)
except:
pass
- app = MyApp(wx.Platform == "__WXMAC__")
+ app = MyApp(0) ##wx.Platform == "__WXMAC__")
app.MainLoop()
@@ -941,13 +950,12 @@ def main():
overview = """
wxPython is a GUI toolkit for the Python 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 wxWindows cross -platform GUI library, which is written in C++. +
wxPython is a GUI toolkit for the Python 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 wxWindows cross platform GUI library, which is +written in C++.
Like Python and wxWindows, wxPython is Open Source which means that it is free for anyone to use and the source code is