1 | #!/usr/bin/python |
---|
2 | """ |
---|
3 | Help panel for calculator |
---|
4 | """ |
---|
5 | import os |
---|
6 | import wx |
---|
7 | import wx.html as html |
---|
8 | from wx.lib.splitter import MultiSplitterWindow |
---|
9 | import sas.perspectives.calculator as calculator |
---|
10 | |
---|
11 | |
---|
12 | class HelpWindow(wx.Frame): |
---|
13 | """ |
---|
14 | """ |
---|
15 | def __init__(self, parent, id=-1, title="Tool Help", pageToOpen=None, |
---|
16 | size=(700, 450)): |
---|
17 | wx.Frame.__init__(self, parent, id, title, size=size) |
---|
18 | """ |
---|
19 | contains help info |
---|
20 | """ |
---|
21 | self.SetTitle(title) |
---|
22 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
23 | rpanel = wx.Panel(splitter, -1) |
---|
24 | self.lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) |
---|
25 | |
---|
26 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
27 | header = wx.Panel(rpanel, -1) |
---|
28 | header.SetBackgroundColour('#6666FF') |
---|
29 | header.SetForegroundColour('WHITE') |
---|
30 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
31 | st = wx.StaticText(header, -1, 'Contents', (5, 5)) |
---|
32 | font = st.GetFont() |
---|
33 | font.SetPointSize(10) |
---|
34 | st.SetFont(font) |
---|
35 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
36 | header.SetSizer(hbox) |
---|
37 | vbox.Add(header, 0, wx.EXPAND) |
---|
38 | |
---|
39 | vboxl = wx.BoxSizer(wx.VERTICAL) |
---|
40 | headerl = wx.Panel(self.lpanel, -1, size=(-1, 20)) |
---|
41 | |
---|
42 | headerl.SetBackgroundColour('#6666FF') |
---|
43 | headerl.SetForegroundColour('WHITE') |
---|
44 | hboxl = wx.BoxSizer(wx.HORIZONTAL) |
---|
45 | lst = wx.StaticText(headerl, -1, 'Menu', (5, 5)) |
---|
46 | fontl = lst.GetFont() |
---|
47 | fontl.SetPointSize(10) |
---|
48 | lst.SetFont(fontl) |
---|
49 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
50 | headerl.SetSizer(hboxl) |
---|
51 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
52 | self.lhelp = html.HtmlWindow(self.lpanel, -1, style=wx.NO_BORDER) |
---|
53 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, |
---|
54 | size=(500,-1)) |
---|
55 | if pageToOpen != None: |
---|
56 | path = os.path.dirname(pageToOpen) |
---|
57 | self.path = os.path.join(path, "gen_sans_help.html") |
---|
58 | else: |
---|
59 | self.path = calculator.get_data_path(media='media') |
---|
60 | |
---|
61 | page1 = """<html> |
---|
62 | <body> |
---|
63 | <p>Select topic on Menu</p> |
---|
64 | </body> |
---|
65 | </html>""" |
---|
66 | self.rhelp.SetPage(page1) |
---|
67 | page = """<html> |
---|
68 | <body> |
---|
69 | <ul> |
---|
70 | <li><a href ="data_operator_help.html" |
---|
71 | target ="showframe">Data Operator</a><br></li> |
---|
72 | <li><a href ="sld_calculator_help.html" |
---|
73 | target ="showframe">SLD Calculator</a><br></li> |
---|
74 | <li><a href ="density_calculator_help.html" |
---|
75 | target ="showframe">Density Calculator</a><br></li> |
---|
76 | <li><a href ="slit_calculator_help.html" |
---|
77 | target ="showframe">Slit Size Calculator</a><br></li> |
---|
78 | <li><a href ="kiessig_calculator_help.html" |
---|
79 | target ="showframe">Kiessig Thickness Calculator</a><br></li> |
---|
80 | <li><a href ="resolution_calculator_help.html" |
---|
81 | target ="showframe">Resolution Estimator</a><br></li> |
---|
82 | <li><a href ="gen_sans_help.html" |
---|
83 | target ="showframe">Generic Scattering Calculator</a><br></li> |
---|
84 | <li><a href ="pycrust_help.html" |
---|
85 | target ="showframe">Python Shell</a><br></li> |
---|
86 | <li><a href ="load_image_help.html" |
---|
87 | target ="showframe">Image Viewer</a><br></li> |
---|
88 | </ul> |
---|
89 | </body> |
---|
90 | </html>""" |
---|
91 | |
---|
92 | self.lhelp.SetPage(page) |
---|
93 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) |
---|
94 | if pageToOpen != None: |
---|
95 | self.rhelp.LoadPage(str(pageToOpen)) |
---|
96 | vbox.Add(self.rhelp, 1, wx.EXPAND) |
---|
97 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
98 | rpanel.SetSizer(vbox) |
---|
99 | self.lpanel.SetSizer(vboxl) |
---|
100 | self.lpanel.SetFocus() |
---|
101 | |
---|
102 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
103 | vbox1.Add(splitter, 1, wx.EXPAND) |
---|
104 | splitter.AppendWindow(self.lpanel, 200) |
---|
105 | splitter.AppendWindow(rpanel) |
---|
106 | self.SetSizer(vbox1) |
---|
107 | |
---|
108 | self.splitter = splitter |
---|
109 | self.Centre() |
---|
110 | self.Show(True) |
---|
111 | |
---|
112 | def OnLinkClicked(self, event): |
---|
113 | """ |
---|
114 | Function to diplay html page related to the hyperlinktext selected |
---|
115 | """ |
---|
116 | link = event.GetLinkInfo().GetHref() |
---|
117 | link = os.path.join(self.path, link) |
---|
118 | self.rhelp.LoadPage(link) |
---|
119 | |
---|
120 | |
---|
121 | class ViewApp(wx.App): |
---|
122 | def OnInit(self): |
---|
123 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
124 | frame.Show(True) |
---|
125 | self.SetTopWindow(frame) |
---|
126 | return True |
---|
127 | |
---|
128 | if __name__ == "__main__": |
---|
129 | app = ViewApp(0) |
---|
130 | app.MainLoop() |
---|