]>
Commit | Line | Data |
---|---|---|
d1dc2b32 RD |
1 | #---------------------------------------------------------------------------- |
2 | # Name: PyDocViewDemo.py | |
3 | # Purpose: Demo of Python extensions to the wxWindows docview framework | |
4 | # | |
5 | # Author: Peter Yared, Morgan Hua | |
6 | # | |
7 | # Created: 5/15/03 | |
8 | # CVS-ID: $Id$ | |
9 | # Copyright: (c) 2003 ActiveGrid, Inc. | |
10 | # License: wxWindows license | |
11 | #---------------------------------------------------------------------------- | |
12 | ||
13 | ||
14 | import sys | |
15 | import wx | |
16 | import wx.lib.docview | |
17 | import wx.lib.pydocview | |
18 | import activegrid.tool.TextEditor as TextEditor | |
19 | import activegrid.tool.FindService as FindService | |
74b89458 RD |
20 | _ = wx.GetTranslation |
21 | ||
d1dc2b32 RD |
22 | |
23 | #---------------------------------------------------------------------------- | |
24 | # Classes | |
25 | #---------------------------------------------------------------------------- | |
26 | ||
27 | class TextEditorApplication(wx.lib.pydocview.DocApp): | |
28 | ||
29 | ||
30 | def OnInit(self): | |
31 | wx.lib.pydocview.DocApp.OnInit(self) | |
32 | ||
33 | wx.lib.pydocview.DocApp.ShowSplash(self, "activegrid/tool/images/splash.jpg") | |
34 | ||
74b89458 | 35 | self.SetAppName(_("wxPython PyDocView Demo")) |
d1dc2b32 RD |
36 | config = wx.Config(self.GetAppName(), style = wx.CONFIG_USE_LOCAL_FILE) |
37 | ||
38 | docManager = wx.lib.docview.DocManager(flags = self.GetDefaultDocManagerFlags()) | |
39 | self.SetDocumentManager(docManager) | |
40 | ||
41 | textTemplate = wx.lib.docview.DocTemplate(docManager, | |
74b89458 | 42 | _("Text"), |
d1dc2b32 | 43 | "*.text;*.txt", |
74b89458 RD |
44 | _("Text"), |
45 | _(".txt"), | |
46 | _("Text Document"), | |
47 | _("Text View"), | |
d1dc2b32 RD |
48 | TextEditor.TextDocument, |
49 | TextEditor.TextView) | |
50 | docManager.AssociateTemplate(textTemplate) | |
51 | ||
52 | textService = self.InstallService(TextEditor.TextService()) | |
53 | findService = self.InstallService(FindService.FindService()) | |
54 | optionsService = self.InstallService(wx.lib.pydocview.DocOptionsService()) | |
74b89458 | 55 | windowMenuService = self.InstallService(wx.lib.pydocview.WindowMenuService()) |
d1dc2b32 RD |
56 | optionsService.AddOptionsPanel(TextEditor.TextOptionsPanel) |
57 | filePropertiesService = self.InstallService(wx.lib.pydocview.FilePropertiesService()) | |
74b89458 | 58 | aboutService = self.InstallService(wx.lib.pydocview.AboutService()) |
d1dc2b32 | 59 | |
74b89458 | 60 | ## self.SetDefaultIcon(getAppIcon()) # set this for your custom icon |
d1dc2b32 RD |
61 | |
62 | if docManager.GetFlags() & wx.lib.docview.DOC_MDI: | |
63 | frame = wx.lib.pydocview.DocMDIParentFrame(docManager, None, -1, wx.GetApp().GetAppName()) | |
64 | frame.Show(True) | |
65 | ||
66 | wx.lib.pydocview.DocApp.CloseSplash(self) | |
67 | ||
68 | self.OpenCommandLineArgs() | |
69 | ||
70 | if not docManager.GetDocuments() and docManager.GetFlags() & wx.lib.docview.DOC_SDI: | |
71 | textTemplate.CreateDocument('', wx.lib.docview.DOC_NEW).OnNewDocument() | |
72 | ||
74b89458 | 73 | wx.CallAfter(self.ShowTip, wx.GetApp().GetTopWindow(), wx.CreateFileTipProvider("activegrid/tool/data/tips.txt", 0)) |
d1dc2b32 RD |
74 | |
75 | return True | |
76 | ||
77 | ||
d1dc2b32 RD |
78 | #---------------------------------------------------------------------------- |
79 | # Main | |
80 | #---------------------------------------------------------------------------- | |
81 | ||
82 | sys.stdout = sys.stderr | |
83 | ||
84 | app = TextEditorApplication(redirect = False) | |
85 | app.MainLoop() |