]>
Commit | Line | Data |
---|---|---|
5ca24bf4 HH |
1 | from wxPython.wx import * |
2 | from wxPython.html import * | |
3 | import sys,os | |
4 | ||
5 | if not os.environ.has_key('WXWIN'): | |
6 | print "Can't find html samples. Set WXWIN environment variable." | |
7 | sys.exit(1) | |
8 | ||
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") | |
13 | ||
14 | class HelpFrame(wxFrame): | |
15 | def __init__(self): | |
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)) | |
22 | ||
23 | html = wxHtmlWindow(self,-1) | |
24 | html.SetRelatedFrame(self, "%s") | |
25 | html.SetRelatedStatusBar(0) | |
26 | ||
27 | self.searchframe = wxMiniFrame(self, -1, "Search result", wxDefaultPosition, wxSize(300,400)) | |
28 | self.searchbox = wxListBox(self.searchframe, wxID_HTML_SEARCHLIST) | |
29 | ||
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() | |
44 | ||
45 | def ToggleContents(self, event): | |
46 | self.mframe.Show(not self.mframe.IsShown()) | |
47 | ||
48 | def OnCloseContents(self, event): | |
49 | if event.CanVeto(): | |
50 | self.mframe.Show(FALSE) | |
51 | else: | |
52 | self.mframe.Destroy() | |
53 | ||
54 | def OnCloseSearch(self, event): | |
55 | if event.CanVeto(): | |
56 | self.searchframe.Show(FALSE) | |
57 | else: | |
58 | self.searchframe.Destroy() | |
59 | ||
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()) | |
65 | ||
66 | class MyApp(wxApp): | |
67 | def OnInit(self): | |
68 | frame = HelpFrame() | |
69 | frame.Show(TRUE) | |
70 | return TRUE | |
71 | ||
72 | theApp = MyApp(0) | |
73 | theApp.MainLoop() |