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