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 sans.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 | </ul> |
---|
87 | </body> |
---|
88 | </html>""" |
---|
89 | |
---|
90 | self.lhelp.SetPage(page) |
---|
91 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) |
---|
92 | if pageToOpen != None: |
---|
93 | self.rhelp.LoadPage(str(pageToOpen)) |
---|
94 | vbox.Add(self.rhelp, 1, wx.EXPAND) |
---|
95 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
96 | rpanel.SetSizer(vbox) |
---|
97 | self.lpanel.SetSizer(vboxl) |
---|
98 | self.lpanel.SetFocus() |
---|
99 | |
---|
100 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
101 | vbox1.Add(splitter, 1, wx.EXPAND) |
---|
102 | splitter.AppendWindow(self.lpanel, 200) |
---|
103 | splitter.AppendWindow(rpanel) |
---|
104 | self.SetSizer(vbox1) |
---|
105 | |
---|
106 | self.splitter = splitter |
---|
107 | self.Centre() |
---|
108 | self.Show(True) |
---|
109 | |
---|
110 | def OnLinkClicked(self, event): |
---|
111 | """ |
---|
112 | Function to diplay html page related to the hyperlinktext selected |
---|
113 | """ |
---|
114 | link = event.GetLinkInfo().GetHref() |
---|
115 | link = os.path.join(self.path, link) |
---|
116 | self.rhelp.LoadPage(link) |
---|
117 | |
---|
118 | |
---|
119 | class ViewApp(wx.App): |
---|
120 | def OnInit(self): |
---|
121 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
122 | frame.Show(True) |
---|
123 | self.SetTopWindow(frame) |
---|
124 | return True |
---|
125 | |
---|
126 | if __name__ == "__main__": |
---|
127 | app = ViewApp(0) |
---|
128 | app.MainLoop() |
---|