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