]>
Commit | Line | Data |
---|---|---|
4f3449b4 RD |
1 | |
2 | from wxPython.wx import * | |
3 | from wxPython.help import * | |
4 | ||
5 | #---------------------------------------------------------------------- | |
6 | # We first have to set an application wide help provider. Normally you | |
7 | # would do this in your app's OnInit or in other startup code... | |
8 | ||
9 | provider = wxSimpleHelpProvider() | |
10 | wxHelpProvider_Set(provider) | |
11 | ||
12 | ||
13 | class TestPanel(wxPanel): | |
14 | def __init__(self, parent, log): | |
15 | wxPanel.__init__(self, parent, -1) | |
16 | self.log = log | |
17 | ||
18 | self.SetHelpText("This is a wxPanel.") | |
19 | sizer = wxBoxSizer(wxVERTICAL) | |
20 | ||
21 | cBtn = wxContextHelpButton(self) | |
22 | cBtn.SetHelpText("wxContextHelpButton") | |
23 | cBtnText = wxStaticText(self, -1, "This is a wxContextHelpButton. Clicking it puts the\n" | |
24 | "app into context sensitive help mode.") | |
25 | cBtnText.SetHelpText("Some helpful text...") | |
26 | ||
27 | s = wxBoxSizer(wxHORIZONTAL) | |
28 | s.Add(cBtn, 0, wxALL, 5) | |
29 | s.Add(cBtnText, 0, wxALL, 5) | |
30 | sizer.Add(20,20) | |
31 | sizer.Add(s) | |
32 | ||
33 | text = wxTextCtrl(self, -1, "Each sub-window can have its own help message", | |
34 | size=(240, 60), style = wxTE_MULTILINE) | |
35 | text.SetHelpText("This is my very own help message. This is a really long long long long long long long long long long long long long long long long long long long long message!") | |
36 | sizer.Add(20,20) | |
37 | sizer.Add(text) | |
38 | ||
39 | text = wxTextCtrl(self, -1, "You can also intercept the help event if you like. Watch the log window when you click here...", | |
40 | size=(240, 60), style = wxTE_MULTILINE) | |
41 | text.SetHelpText("Yet another context help message.") | |
42 | sizer.Add(20,20) | |
43 | sizer.Add(text) | |
44 | EVT_HELP(text, text.GetId(), self.OnCtxHelp) | |
45 | ||
46 | text = wxTextCtrl(self, -1, "This one displays the tip itself...", | |
47 | size=(240, 60), style = wxTE_MULTILINE) | |
48 | sizer.Add(20,20) | |
49 | sizer.Add(text) | |
50 | EVT_HELP(text, text.GetId(), self.OnCtxHelp2) | |
51 | ||
52 | ||
53 | border = wxBoxSizer(wxVERTICAL) | |
54 | border.Add(sizer, 0, wxALL, 25) | |
55 | ||
56 | self.SetAutoLayout(true) | |
57 | self.SetSizer(border) | |
58 | self.Layout() | |
59 | ||
60 | ||
61 | def OnCtxHelp(self, evt): | |
62 | self.log.write("OnCtxHelp: %s" % evt) | |
63 | evt.Skip() | |
64 | ||
65 | ||
66 | def OnCtxHelp2(self, evt): | |
67 | self.log.write("OnCtxHelp: %s" % evt) | |
68 | tip = wxTipWindow(self, "This is a wxTipWindow") | |
69 | ||
70 | ||
71 | #---------------------------------------------------------------------- | |
72 | ||
73 | def runTest(frame, nb, log): | |
74 | win = TestPanel(nb, log) | |
75 | return win | |
76 | ||
77 | ||
78 | #---------------------------------------------------------------------- | |
79 | ||
80 | ||
81 | ||
82 | ||
83 | overview = """ | |
84 | This demo shows how to encorporate Context Sensitive | |
85 | help into your applicaiton using the wxSimpleHelpProvider class. | |
86 | ||
87 | """ | |
88 | ||
89 | ||
90 | ||
91 | #---------------------------------------------------------------------- | |
92 |