]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/modules/html/test/helpsys.py
1 from wxPython
.wx
import *
2 from wxPython
.html
import *
5 if not os
.environ
.has_key('WXWIN'):
6 print "Can't find html samples. Set WXWIN environment variable."
9 help = wxHtmlHelpSystem()
10 # Create the book in a different way, supply title, contents file, index, default topic and basedir
11 help.AddBookParam('Sample help docs', 'contents.hhc', '', 'main.htm',
12 os
.environ
['WXWIN'] + "/samples/html/help/helpfiles")
14 class HelpFrame(wxFrame
):
16 wxFrame
.__init
__(self
, NULL
, -1, "", wxDefaultPosition
, wxSize(500,500))
17 bar
= self
.CreateStatusBar(2)
18 bar
.SetStatusWidths([400,100])
19 help.CreateToolBar(self
)
20 self
.text
= wxTextCtrl(bar
, 1001, "Hello world", wxPoint(400,0), wxSize(80,30))
21 button
= wxButton(bar
, 1002, "Go", wxPoint(480,0), wxSize(20,30))
23 html
= wxHtmlWindow(self
,-1)
24 html
.SetRelatedFrame(self
, "%s")
25 html
.SetRelatedStatusBar(0)
27 self
.searchframe
= wxMiniFrame(self
, -1, "Search result", wxDefaultPosition
, wxSize(300,400))
28 self
.searchbox
= wxListBox(self
.searchframe
, wxID_HTML_SEARCHLIST
)
30 self
.mframe
= wxMiniFrame(self
, -1, "Contents", wxDefaultPosition
, wxSize(300,500))
31 tree
= help.CreateContentsTree(self
.mframe
)
32 help.SetControls(self
, html
, tree
, NULL
, self
.searchbox
)
33 EVT_TREE_SEL_CHANGED(self
, wxID_HTML_TREECTRL
, help.OnContentsSel
)
34 EVT_LISTBOX(self
, wxID_HTML_SEARCHLIST
, help.OnSearchSel
)
35 EVT_TOOL(self
, wxID_HTML_PANEL
, self
.ToggleContents
)
36 EVT_TOOL(self
, wxID_HTML_BACK
, help.OnToolbar
)
37 EVT_TOOL(self
, wxID_HTML_FORWARD
, help.OnToolbar
)
38 EVT_TEXT_ENTER(self
, 1001, self
.OnTextSearch
)
39 EVT_BUTTON(self
, 1002, self
.OnTextSearch
)
40 EVT_CLOSE(self
.mframe
, self
.OnCloseContents
)
41 EVT_CLOSE(self
.searchframe
, self
.OnCloseSearch
)
42 self
.mframe
.Show(TRUE
)
43 print help.GetSearchList()
45 def ToggleContents(self
, event
):
46 self
.mframe
.Show(not self
.mframe
.IsShown())
48 def OnCloseContents(self
, event
):
50 self
.mframe
.Show(FALSE
)
54 def OnCloseSearch(self
, event
):
56 self
.searchframe
.Show(FALSE
)
58 self
.searchframe
.Destroy()
60 def OnTextSearch(self
, event
):
61 self
.searchbox
.Clear()
62 self
.searchframe
.Show(TRUE
)
63 print "searching for %s" % (self
.text
.GetValue(),)
64 help.KeywordSearch(self
.text
.GetValue())