]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/tools/helpviewer.py
cursor image type fix
[wxWidgets.git] / wxPython / wx / tools / helpviewer.py
1 #----------------------------------------------------------------------
2 # Name: wx.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 makeOtherFrame(helpctrl):
30 import wx
31 parent = helpctrl.GetFrame()
32 otherFrame = wx.Frame(parent)
33
34
35 def main(args=sys.argv):
36 if len(args) < 2:
37 print __doc__
38 return
39
40 args = args[1:]
41 cachedir = None
42 if args[0][:7] == '--cache':
43 cachedir = os.path.expanduser(args[0].split('=')[1])
44 args = args[1:]
45
46 if len(args) == 0:
47 print __doc__
48 return
49
50 import wx
51 import wx.html
52
53 app = wx.PySimpleApp()
54 #wx.Log.SetActiveTarget(wx.LogStderr())
55 wx.Log.SetLogLevel(wx.LOG_Error)
56
57 # Set up the default config so the htmlhelp frame can save its preferences
58 app.SetVendorName('wxWindows')
59 app.SetAppName('helpviewer')
60 cfg = wx.ConfigBase.Get()
61
62 # Add the Zip filesystem
63 wx.FileSystem.AddHandler(wx.ZipFSHandler())
64
65 # Create the viewer
66 helpctrl = wx.html.HtmlHelpController()
67 if cachedir:
68 helpctrl.SetTempDir(cachedir)
69
70 # and add the books
71 for helpfile in args:
72 print "Adding %s..." % helpfile
73 helpctrl.AddBook(helpfile, 1)
74
75 # The frame used by the HtmlHelpController is set to not prevent
76 # app exit, so in the case of a standalone helpviewer like this
77 # when the about box or search box is closed the help frame will
78 # be the only one left and the app will close unexpectedly. To
79 # work around this we'll create another frame that is never shown,
80 # but which will be closed when the helpviewer frame is closed.
81 wx.CallAfter(makeOtherFrame, helpctrl)
82
83 # start it up!
84 helpctrl.DisplayContents()
85 app.MainLoop()
86
87
88 if __name__ == '__main__':
89 main()
90
91