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