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 ActiveGrid, Inc.
10 # License: wxWindows license
11 #----------------------------------------------------------------------------
17 import wx
.lib
.pydocview
18 import activegrid
.tool
.TextEditor
as TextEditor
19 import activegrid
.tool
.FindService
as FindService
23 #----------------------------------------------------------------------------
25 #----------------------------------------------------------------------------
27 class TextEditorApplication(wx
.lib
.pydocview
.DocApp
):
31 wx
.lib
.pydocview
.DocApp
.OnInit(self
)
33 wx
.lib
.pydocview
.DocApp
.ShowSplash(self
, "activegrid/tool/images/splash.jpg")
35 self
.SetAppName(_("wxPython PyDocView Demo"))
36 config
= wx
.Config(self
.GetAppName(), style
= wx
.CONFIG_USE_LOCAL_FILE
)
38 docManager
= wx
.lib
.docview
.DocManager(flags
= self
.GetDefaultDocManagerFlags())
39 self
.SetDocumentManager(docManager
)
41 textTemplate
= wx
.lib
.docview
.DocTemplate(docManager
,
48 TextEditor
.TextDocument
,
50 docManager
.AssociateTemplate(textTemplate
)
52 textService
= self
.InstallService(TextEditor
.TextService())
53 findService
= self
.InstallService(FindService
.FindService())
54 optionsService
= self
.InstallService(wx
.lib
.pydocview
.DocOptionsService())
55 windowMenuService
= self
.InstallService(wx
.lib
.pydocview
.WindowMenuService())
56 optionsService
.AddOptionsPanel(TextEditor
.TextOptionsPanel
)
57 filePropertiesService
= self
.InstallService(wx
.lib
.pydocview
.FilePropertiesService())
58 aboutService
= self
.InstallService(wx
.lib
.pydocview
.AboutService())
60 ## self.SetDefaultIcon(getAppIcon()) # set this for your custom icon
62 if docManager
.GetFlags() & wx
.lib
.docview
.DOC_MDI
:
63 frame
= wx
.lib
.pydocview
.DocMDIParentFrame(docManager
, None, -1, wx
.GetApp().GetAppName())
66 wx
.lib
.pydocview
.DocApp
.CloseSplash(self
)
68 self
.OpenCommandLineArgs()
70 if not docManager
.GetDocuments() and docManager
.GetFlags() & wx
.lib
.docview
.DOC_SDI
:
71 textTemplate
.CreateDocument('', wx
.lib
.docview
.DOC_NEW
).OnNewDocument()
73 wx
.CallAfter(self
.ShowTip
, wx
.GetApp().GetTopWindow(), wx
.CreateFileTipProvider("activegrid/tool/data/tips.txt", 0))
78 #----------------------------------------------------------------------------
80 #----------------------------------------------------------------------------
82 sys
.stdout
= sys
.stderr
84 app
= TextEditorApplication(redirect
= False)