]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/pydocview/PyDocViewDemo.py
1 #----------------------------------------------------------------------------
2 # Name: PyDocViewDemo.py
3 # Purpose: Demo of Python extensions to the wxWindows docview framework
5 # Author: Peter Yared, Morgan Hua
9 # Copyright: (c) 2003-2005 ActiveGrid, Inc.
10 # License: ASL 2.0 http://apache.org/licenses/LICENSE-2.0
11 #----------------------------------------------------------------------------
16 import wx
.lib
.docview
as docview
17 import wx
.lib
.pydocview
as pydocview
23 #----------------------------------------------------------------------------
25 #----------------------------------------------------------------------------
27 class TextEditorApplication(pydocview
.DocApp
):
31 # Call the super - this is important!!!
32 pydocview
.DocApp
.OnInit(self
)
34 # Show the splash dialog while everything is loading up
35 self
.ShowSplash("splash.jpg")
37 # Set the name and the icon
38 self
.SetAppName(_("wxPython PyDocView Demo"))
39 self
.SetDefaultIcon(pydocview
.getBlankIcon())
41 # Initialize the document manager
42 docManager
= docview
.DocManager(flags
= self
.GetDefaultDocManagerFlags())
43 self
.SetDocumentManager(docManager
)
45 # Create a template for text documents and associate it with the docmanager
46 textTemplate
= docview
.DocTemplate(docManager
,
53 TextEditor
.TextDocument
,
55 icon
=pydocview
.getBlankIcon())
56 docManager
.AssociateTemplate(textTemplate
)
58 # Install services - these can install menu and toolbar items
59 textService
= self
.InstallService(TextEditor
.TextService())
60 findService
= self
.InstallService(FindService
.FindService())
61 optionsService
= self
.InstallService(pydocview
.DocOptionsService())
62 windowMenuService
= self
.InstallService(pydocview
.WindowMenuService())
63 filePropertiesService
= self
.InstallService(pydocview
.FilePropertiesService())
64 aboutService
= self
.InstallService(pydocview
.AboutService(image
=wx
.Image("splash.jpg")))
66 # Install the TextEditor's option panel into the OptionsService
67 optionsService
.AddOptionsPanel(TextEditor
.TextOptionsPanel
)
69 # If it is an MDI app open the main frame
72 # Open any files that were passed via the command line
73 self
.OpenCommandLineArgs()
75 # If nothing was opened and it is an SDI app, open up an empty text document
76 if not docManager
.GetDocuments() and docManager
.GetFlags() & wx
.lib
.docview
.DOC_SDI
:
77 textTemplate
.CreateDocument('', docview
.DOC_NEW
).OnNewDocument()
79 # Close the splash dialog
82 # Show the tips dialog
83 wx
.CallAfter(self
.ShowTip
, wx
.GetApp().GetTopWindow(), wx
.CreateFileTipProvider("tips.txt", 0))
85 # Tell the framework that everything is great
89 #----------------------------------------------------------------------------
91 #----------------------------------------------------------------------------
93 # Run the TextEditorApplication and do not redirect output to the wxPython error dialog
94 app
= TextEditorApplication(redirect
=False)