]> git.saurik.com Git - wxWidgets.git/blame - wxPython/samples/wxPIA_book/Chapter-16/html_help.py
fixed deadlock when calling wxPostEvent() from worker thread
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-16 / html_help.py
CommitLineData
be05b434
RD
1"""
2wxPython can use html files for online help or other forms of
3documentation for your application. The help can be organized as a
4collection of books, and there is a help viewer available that enables
5the user to browse by book, via an index or full text search. The
6format of the contents and index files are similar to Microsoft
7HtmlHelp.
8"""
9
10import wx
11import wx.html
12
13class MyHtmlFrame(wx.Frame):
14 def __init__(self, parent, title):
15 wx.Frame.__init__(self, parent, -1, title)
16 p = wx.Panel(self)
17 b1 = wx.Button(p, -1, "Show Help Contents")
18 b2 = wx.Button(p, -1, "Show Help Index")
19 b3 = wx.Button(p, -1, "Show Specific Help")
20 self.Bind(wx.EVT_BUTTON, self.OnShowHelpContents, b1)
21 self.Bind(wx.EVT_BUTTON, self.OnShowHelpIndex, b2)
22 self.Bind(wx.EVT_BUTTON, self.OnShowSpecificHelp, b3)
23
24 sizer = wx.BoxSizer(wx.VERTICAL)
25 sizer.Add((10,10))
26 sizer.Add(b1, 0, wx.ALL, 10)
27 sizer.Add(b2, 0, wx.ALL, 10)
28 sizer.Add(b3, 0, wx.ALL, 10)
29 p.SetSizer(sizer)
30
31 self.InitHelp()
32
33
34 def InitHelp(self):
35 def _addBook(filename):
36 if not self.help.AddBook(filename):
37 wx.MessageBox("Unable to open: " + filename,
38 "Error", wx.OK|wx.ICON_EXCLAMATION)
39
40 self.help = wx.html.HtmlHelpController()
41
42 _addBook("helpfiles/testing.hhp")
43 _addBook("helpfiles/another.hhp")
44
45
46 def OnShowHelpContents(self, evt):
47 self.help.DisplayContents()
48
49 def OnShowHelpIndex(self, evt):
50 self.help.DisplayIndex()
51
52 def OnShowSpecificHelp(self, evt):
53 self.help.Display("sub book")
54
55
56app = wx.PySimpleApp()
57frm = MyHtmlFrame(None, "HTML Help")
58frm.Show()
59app.MainLoop()