1 | #!/usr/bin/python |
---|
2 | """ |
---|
3 | Help panel for plotting |
---|
4 | """ |
---|
5 | import os |
---|
6 | import wx |
---|
7 | import wx.html as html |
---|
8 | from wx.lib.splitter import MultiSplitterWindow |
---|
9 | from sans.guiframe import get_media_path |
---|
10 | |
---|
11 | |
---|
12 | class HelpWindow(wx.Frame): |
---|
13 | """ |
---|
14 | """ |
---|
15 | def __init__(self, parent, title='Plotting Help', pageToOpen=None): |
---|
16 | wx.Frame.__init__(self, parent, title, size=(700, 450)) |
---|
17 | """ |
---|
18 | contains help info |
---|
19 | """ |
---|
20 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
21 | rpanel = wx.Panel(splitter, -1) |
---|
22 | lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) |
---|
23 | |
---|
24 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
25 | header = wx.Panel(rpanel, -1) |
---|
26 | header.SetBackgroundColour('#6666FF') |
---|
27 | header.SetForegroundColour('WHITE') |
---|
28 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
29 | st = wx.StaticText(header, -1, 'Contents', (5, 5)) |
---|
30 | font = st.GetFont() |
---|
31 | font.SetPointSize(10) |
---|
32 | st.SetFont(font) |
---|
33 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
34 | header.SetSizer(hbox) |
---|
35 | vbox.Add(header, 0, wx.EXPAND) |
---|
36 | |
---|
37 | vboxl = wx.BoxSizer(wx.VERTICAL) |
---|
38 | headerl = wx.Panel(lpanel, -1, size=(-1, 20)) |
---|
39 | |
---|
40 | headerl.SetBackgroundColour('#6666FF') |
---|
41 | headerl.SetForegroundColour('WHITE') |
---|
42 | hboxl = wx.BoxSizer(wx.HORIZONTAL) |
---|
43 | lst = wx.StaticText(headerl, -1, 'Menu', (5, 5)) |
---|
44 | fontl = lst.GetFont() |
---|
45 | fontl.SetPointSize(10) |
---|
46 | lst.SetFont(fontl) |
---|
47 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
48 | headerl.SetSizer(hboxl) |
---|
49 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
50 | self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER) |
---|
51 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, |
---|
52 | size=(500,-1)) |
---|
53 | |
---|
54 | self.path = get_media_path(media='media') |
---|
55 | |
---|
56 | page1 = """<html> |
---|
57 | <body> |
---|
58 | <p>Select topic on Menu</p> |
---|
59 | </body> |
---|
60 | </html>""" |
---|
61 | self.rhelp.SetPage(page1) |
---|
62 | page = """<html> |
---|
63 | <body> |
---|
64 | <ul> |
---|
65 | <li><a href ="Graph_help.html" |
---|
66 | target ="showframe">Graph Context Menu</a><br></li> |
---|
67 | <li><a href ="averaging_help.html" |
---|
68 | target ="showframe">2D Data Averaging</a><br></li> |
---|
69 | <li><a href ="key_help.html" |
---|
70 | target ="showframe">Key Combination</a><br></li> |
---|
71 | </ul> |
---|
72 | </body> |
---|
73 | </html>""" |
---|
74 | |
---|
75 | self.lhelp.SetPage(page) |
---|
76 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) |
---|
77 | |
---|
78 | vbox.Add(self.rhelp, 1, wx.EXPAND) |
---|
79 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
80 | rpanel.SetSizer(vbox) |
---|
81 | lpanel.SetSizer(vboxl) |
---|
82 | lpanel.SetFocus() |
---|
83 | |
---|
84 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
85 | vbox1.Add(splitter, 1, wx.EXPAND) |
---|
86 | splitter.AppendWindow(lpanel, 200) |
---|
87 | splitter.AppendWindow(rpanel) |
---|
88 | self.SetSizer(vbox1) |
---|
89 | |
---|
90 | self.Centre() |
---|
91 | self.Show(True) |
---|
92 | |
---|
93 | def OnLinkClicked(self, event): |
---|
94 | """ |
---|
95 | Function to diplay html page related to the hyperlinktext selected |
---|
96 | """ |
---|
97 | link = event.GetLinkInfo().GetHref() |
---|
98 | link = os.path.join(self.path, link) |
---|
99 | self.rhelp.LoadPage(link) |
---|
100 | |
---|
101 | |
---|
102 | class ViewApp(wx.App): |
---|
103 | def OnInit(self): |
---|
104 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
105 | frame.Show(True) |
---|
106 | self.SetTopWindow(frame) |
---|
107 | return True |
---|
108 | |
---|
109 | if __name__ == "__main__": |
---|
110 | app = ViewApp(0) |
---|
111 | app.MainLoop() |
---|