]>
Commit | Line | Data |
---|---|---|
1 | #---------------------------------------------------------------------- | |
2 | # Name: wxPython.tools.helpviewer | |
3 | # Purpose: HTML Help viewer | |
4 | # | |
5 | # Author: Robin Dunn | |
6 | # | |
7 | # Created: 11-Dec-2002 | |
8 | # RCS-ID: $Id$ | |
9 | # Copyright: (c) 2002 by Total Control Software | |
10 | # Licence: wxWindows license | |
11 | #---------------------------------------------------------------------- | |
12 | ||
13 | """ | |
14 | helpviewer.py -- Displays HTML Help in a wxHtmlHelpController window. | |
15 | ||
16 | Usage: | |
17 | helpviewer [--cache=path] helpfile [helpfile(s)...] | |
18 | ||
19 | Where helpfile is the path to either a .hhp file or a .zip file | |
20 | which contians a .hhp file. The .hhp files are the same as those | |
21 | used by Microsoft's HTML Help Workshop for creating CHM files. | |
22 | """ | |
23 | ||
24 | ||
25 | import sys, os | |
26 | ||
27 | #--------------------------------------------------------------------------- | |
28 | ||
29 | def main(args=sys.argv): | |
30 | if len(args) < 2: | |
31 | print __doc__ | |
32 | return | |
33 | ||
34 | args = args[1:] | |
35 | cachedir = None | |
36 | if args[0][:7] == '--cache': | |
37 | cachedir = os.path.expanduser(args[0].split('=')[1]) | |
38 | args = args[1:] | |
39 | ||
40 | if len(args) == 0: | |
41 | print __doc__ | |
42 | return | |
43 | ||
44 | import wx | |
45 | import wx.html | |
46 | ||
47 | app = wx.PySimpleApp() | |
48 | #wx.Log.SetActiveTarget(wx.LogStderr()) | |
49 | wx.Log.SetLogLevel(wx.LOG_Error) | |
50 | ||
51 | # Set up the default config so the htmlhelp frame can save its preferences | |
52 | app.SetVendorName('wxWindows') | |
53 | app.SetAppName('helpviewer') | |
54 | cfg = wx.ConfigBase.Get() | |
55 | ||
56 | # Add the Zip filesystem | |
57 | wx.FileSystem.AddHandler(wx.ZipFSHandler()) | |
58 | ||
59 | # Create the viewer | |
60 | helpctrl = wx.html.HtmlHelpController() | |
61 | if cachedir: | |
62 | helpctrl.SetTempDir(cachedir) | |
63 | ||
64 | # and add the books | |
65 | for helpfile in args: | |
66 | print "Adding %s..." % helpfile | |
67 | helpctrl.AddBook(helpfile, 1) | |
68 | ||
69 | # start it up! | |
70 | helpctrl.DisplayContents() | |
71 | app.MainLoop() | |
72 | ||
73 | ||
74 | if __name__ == '__main__': | |
75 | main() | |
76 | ||
77 |