[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): |
---|
| 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) |
---|
| 18 | lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN) |
---|
| 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) |
---|
| 29 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
| 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) |
---|
| 43 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
| 44 | headerl.SetSizer(hboxl) |
---|
| 45 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
| 46 | self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER) |
---|
| 47 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1)) |
---|
| 48 | page1="""<html> |
---|
| 49 | <body> |
---|
| 50 | <p>Select topic on Menu</p> |
---|
| 51 | </body> |
---|
| 52 | </html>""" |
---|
| 53 | page="""<html> |
---|
| 54 | <body> |
---|
| 55 | <ul> |
---|
[e071b1c] | 56 | <li><a href ="media/model_functions.html" target ="showframe">Model Functions</a><br></li> |
---|
[0277d084] | 57 | </ul> |
---|
| 58 | </body> |
---|
| 59 | </html>""" |
---|
| 60 | self.rhelp.SetPage(page1) |
---|
| 61 | self.lhelp.SetPage(page) |
---|
| 62 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked ) |
---|
| 63 | |
---|
| 64 | #open the help frame a the current page |
---|
| 65 | if pageToOpen!= None: |
---|
| 66 | self.rhelp.LoadPage(str( pageToOpen)) |
---|
| 67 | |
---|
| 68 | vbox.Add(self.rhelp,1, wx.EXPAND) |
---|
| 69 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
| 70 | rpanel.SetSizer(vbox) |
---|
| 71 | lpanel.SetSizer(vboxl) |
---|
| 72 | lpanel.SetFocus() |
---|
| 73 | |
---|
| 74 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 75 | vbox1.Add(splitter,1,wx.EXPAND) |
---|
| 76 | splitter.AppendWindow(lpanel, 200) |
---|
| 77 | splitter.AppendWindow(rpanel) |
---|
| 78 | self.SetSizer(vbox1) |
---|
| 79 | |
---|
| 80 | self.Centre() |
---|
| 81 | self.Show(True) |
---|
| 82 | |
---|
| 83 | def OnButtonClicked(self, event): |
---|
| 84 | """ |
---|
[74755ff] | 85 | Function to diplay html page related to the hyperlinktext selected |
---|
| 86 | |
---|
[0277d084] | 87 | """ |
---|
[e071b1c] | 88 | self.rhelp.LoadPage("media/modelfunction.html") |
---|
[0277d084] | 89 | |
---|
| 90 | def OnLinkClicked(self, event): |
---|
| 91 | """ |
---|
[74755ff] | 92 | Function to diplay html page related to the hyperlinktext selected |
---|
| 93 | |
---|
[0277d084] | 94 | """ |
---|
| 95 | link= event.GetLinkInfo().GetHref() |
---|
| 96 | self.rhelp.LoadPage(link) |
---|
| 97 | |
---|
[74755ff] | 98 | |
---|
[0277d084] | 99 | class ViewApp(wx.App): |
---|
| 100 | def OnInit(self): |
---|
| 101 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
| 102 | frame.Show(True) |
---|
| 103 | self.SetTopWindow(frame) |
---|
| 104 | |
---|
| 105 | return True |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | if __name__ == "__main__": |
---|
| 109 | app = ViewApp(0) |
---|
| 110 | app.MainLoop() |
---|