[427fa87] | 1 | #!/usr/bin/python |
---|
[b0ab6cb] | 2 | """ |
---|
| 3 | Help panel for calculator |
---|
| 4 | """ |
---|
| 5 | import os |
---|
[427fa87] | 6 | import wx |
---|
| 7 | import wx.html as html |
---|
| 8 | from wx.lib.splitter import MultiSplitterWindow |
---|
[1c779b6] | 9 | import sans.perspectives.calculator as calculator |
---|
[427fa87] | 10 | |
---|
| 11 | |
---|
| 12 | class HelpWindow(wx.Frame): |
---|
[b0ab6cb] | 13 | """ |
---|
| 14 | """ |
---|
| 15 | def __init__(self, parent, title='HelpWindow', pageToOpen=None): |
---|
| 16 | wx.Frame.__init__(self, parent, title, size=(700, 450)) |
---|
[427fa87] | 17 | """ |
---|
| 18 | contains help info |
---|
| 19 | """ |
---|
| 20 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
| 21 | rpanel = wx.Panel(splitter, -1) |
---|
[b0ab6cb] | 22 | lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) |
---|
[427fa87] | 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 | |
---|
[b0ab6cb] | 37 | vboxl = wx.BoxSizer(wx.VERTICAL) |
---|
[427fa87] | 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)) |
---|
[1c779b6] | 53 | |
---|
| 54 | self.path = calculator.get_data_path(media='media') |
---|
| 55 | |
---|
[b0ab6cb] | 56 | page1 = """<html> |
---|
[65265c0b] | 57 | <body> |
---|
| 58 | <p>Select topic on Menu</p> |
---|
| 59 | </body> |
---|
| 60 | </html>""" |
---|
[1c779b6] | 61 | self.rhelp.SetPage(page1) |
---|
[b0ab6cb] | 62 | page = """<html> |
---|
[427fa87] | 63 | <body> |
---|
| 64 | <ul> |
---|
[b0ab6cb] | 65 | <li><a href ="sld_calculator_help.html" |
---|
| 66 | target ="showframe">SLD Calculator</a><br></li> |
---|
| 67 | <li><a href ="slit_calculator_help.html" |
---|
| 68 | target ="showframe">Slit Size Calculator</a><br></li> |
---|
| 69 | <li><a href ="kiessig_calculator_help.html" |
---|
| 70 | target ="showframe">Kiessig Thickness Calculator</a><br></li> |
---|
[44ad7f5] | 71 | <li><a href ="resolution_calculator_help.html" |
---|
| 72 | target ="showframe">Resolution Estimator</a><br></li> |
---|
[427fa87] | 73 | </ul> |
---|
| 74 | </body> |
---|
[1c779b6] | 75 | </html>""" |
---|
[65265c0b] | 76 | |
---|
[427fa87] | 77 | self.lhelp.SetPage(page) |
---|
[b0ab6cb] | 78 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) |
---|
[427fa87] | 79 | |
---|
[b0ab6cb] | 80 | vbox.Add(self.rhelp, 1, wx.EXPAND) |
---|
[427fa87] | 81 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
| 82 | rpanel.SetSizer(vbox) |
---|
| 83 | lpanel.SetSizer(vboxl) |
---|
| 84 | lpanel.SetFocus() |
---|
| 85 | |
---|
| 86 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
[b0ab6cb] | 87 | vbox1.Add(splitter, 1, wx.EXPAND) |
---|
[427fa87] | 88 | splitter.AppendWindow(lpanel, 200) |
---|
| 89 | splitter.AppendWindow(rpanel) |
---|
| 90 | self.SetSizer(vbox1) |
---|
| 91 | |
---|
| 92 | self.Centre() |
---|
| 93 | self.Show(True) |
---|
| 94 | |
---|
| 95 | def OnLinkClicked(self, event): |
---|
| 96 | """ |
---|
| 97 | Function to diplay html page related to the hyperlinktext selected |
---|
| 98 | """ |
---|
[b0ab6cb] | 99 | link = event.GetLinkInfo().GetHref() |
---|
| 100 | link = os.path.join(self.path, link) |
---|
[65265c0b] | 101 | self.rhelp.LoadPage(link) |
---|
[1c779b6] | 102 | |
---|
[b0ab6cb] | 103 | |
---|
[427fa87] | 104 | class ViewApp(wx.App): |
---|
| 105 | def OnInit(self): |
---|
| 106 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
| 107 | frame.Show(True) |
---|
| 108 | self.SetTopWindow(frame) |
---|
| 109 | return True |
---|
| 110 | |
---|
| 111 | if __name__ == "__main__": |
---|
| 112 | app = ViewApp(0) |
---|
| 113 | app.MainLoop() |
---|