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