[d7d143b0] | 1 | #!/usr/bin/python |
---|
[5062bbf] | 2 | |
---|
[d7d143b0] | 3 | import wx |
---|
| 4 | import wx.html as html |
---|
[f8b79d6] | 5 | from wx.lib.splitter import MultiSplitterWindow |
---|
[d292959] | 6 | import os |
---|
[925a30e] | 7 | |
---|
[08e1912] | 8 | |
---|
[2268d10] | 9 | class HelpWindow(wx.Frame): |
---|
[5062bbf] | 10 | """ |
---|
| 11 | """ |
---|
[4faf4ba] | 12 | def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None): |
---|
[389c991] | 13 | wx.Frame.__init__(self, parent, id, title, size=(850, 530)) |
---|
[925a30e] | 14 | """ |
---|
[5062bbf] | 15 | contains help info |
---|
[925a30e] | 16 | """ |
---|
[08e1912] | 17 | |
---|
[f8b79d6] | 18 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
| 19 | rpanel = wx.Panel(splitter, -1) |
---|
| 20 | lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN) |
---|
[d7d143b0] | 21 | |
---|
| 22 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
[6fb01b6] | 23 | header = wx.Panel(rpanel, -1) |
---|
[d7d143b0] | 24 | header.SetBackgroundColour('#6666FF') |
---|
| 25 | header.SetForegroundColour('WHITE') |
---|
| 26 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
[2268d10] | 27 | st = wx.StaticText(header, -1, 'Contents', (5, 5)) |
---|
[d7d143b0] | 28 | font = st.GetFont() |
---|
| 29 | font.SetPointSize(10) |
---|
| 30 | st.SetFont(font) |
---|
| 31 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
| 32 | header.SetSizer(hbox) |
---|
| 33 | vbox.Add(header, 0, wx.EXPAND) |
---|
| 34 | |
---|
[b92884a] | 35 | vboxl= wx.BoxSizer(wx.VERTICAL) |
---|
| 36 | headerl = wx.Panel(lpanel, -1, size=(-1, 20)) |
---|
[d292959] | 37 | |
---|
[b92884a] | 38 | headerl.SetBackgroundColour('#6666FF') |
---|
| 39 | headerl.SetForegroundColour('WHITE') |
---|
| 40 | hboxl = wx.BoxSizer(wx.HORIZONTAL) |
---|
[2268d10] | 41 | lst = wx.StaticText(headerl, -1, 'Menu', (5, 5)) |
---|
[b92884a] | 42 | fontl = lst.GetFont() |
---|
| 43 | fontl.SetPointSize(10) |
---|
| 44 | lst.SetFont(fontl) |
---|
| 45 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
| 46 | headerl.SetSizer(hboxl) |
---|
| 47 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
| 48 | self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER) |
---|
[6fb01b6] | 49 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1)) |
---|
[18cdddb] | 50 | |
---|
| 51 | # get the media path |
---|
[70b760da] | 52 | if pageToOpen != None: |
---|
| 53 | path = os.path.dirname(pageToOpen) |
---|
| 54 | else: |
---|
| 55 | from sans.models import get_data_path as model_path |
---|
| 56 | # Get models help model_function path |
---|
| 57 | path = model_path(media='media') |
---|
| 58 | |
---|
[18cdddb] | 59 | self.path = os.path.join(path,"model_functions.html") |
---|
[389c991] | 60 | self.path_pd = os.path.join(path,"pd_help.html") |
---|
[384647dc] | 61 | self.path_sm = os.path.join(path,"smear_computation.html") |
---|
[70b760da] | 62 | from sans.perspectives.fitting import get_data_path as fit_path |
---|
| 63 | fitting_path = fit_path(media='media') |
---|
[c0a30a24] | 64 | |
---|
| 65 | _html_file = {"status_bar_help.html":"Status Bar Help", |
---|
| 66 | "load_data_help.html":"Load a File", |
---|
| 67 | "simultaneous_fit_help.html":"Simultaneous Fit", |
---|
| 68 | "single_fit_help.html":"Single Fit", |
---|
| 69 | "model_use_help.html":"Model Selection", |
---|
| 70 | "key_help.html":"Key Combination", |
---|
| 71 | } |
---|
| 72 | |
---|
[18cdddb] | 73 | |
---|
[2268d10] | 74 | page1="""<html> |
---|
| 75 | <body> |
---|
| 76 | <p>Select topic on Menu</p> |
---|
| 77 | </body> |
---|
| 78 | </html>""" |
---|
[08e1912] | 79 | page="""<html> |
---|
[b92884a] | 80 | <body> |
---|
| 81 | <ul> |
---|
[c0a30a24] | 82 | """ |
---|
| 83 | for p, title in _html_file.iteritems(): |
---|
| 84 | pp = os.path.join(fitting_path, p) |
---|
| 85 | page += """<li><a href ="%s" target="showframe">%s</a><br></li>""" % (pp, title) |
---|
| 86 | |
---|
| 87 | page += """ |
---|
| 88 | <li><a href ="%s" target="showframe">Model Functions</a><br></li> |
---|
| 89 | <li><a href ="%s" target="showframe">Polydispersion Distributions</a><br></li> |
---|
| 90 | <li><a href ="%s" target="showframe">Smear Computation</a><br></li> |
---|
[b92884a] | 91 | </ul> |
---|
| 92 | </body> |
---|
[08e1912] | 93 | </html>""" % (self.path, self.path_pd, self.path_sm) |
---|
[18cdddb] | 94 | |
---|
[2268d10] | 95 | self.rhelp.SetPage(page1) |
---|
[b92884a] | 96 | self.lhelp.SetPage(page) |
---|
| 97 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked ) |
---|
[9181512] | 98 | |
---|
[4faf4ba] | 99 | #open the help frame a the current page |
---|
| 100 | if pageToOpen!= None: |
---|
| 101 | self.rhelp.LoadPage(str( pageToOpen)) |
---|
[9181512] | 102 | |
---|
[dcd330b] | 103 | vbox.Add(self.rhelp,1, wx.EXPAND) |
---|
[b92884a] | 104 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
[d7d143b0] | 105 | rpanel.SetSizer(vbox) |
---|
[b92884a] | 106 | lpanel.SetSizer(vboxl) |
---|
| 107 | lpanel.SetFocus() |
---|
[d7d143b0] | 108 | |
---|
[f8b79d6] | 109 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 110 | vbox1.Add(splitter,1,wx.EXPAND) |
---|
| 111 | splitter.AppendWindow(lpanel, 200) |
---|
| 112 | splitter.AppendWindow(rpanel) |
---|
[d7d143b0] | 113 | self.SetSizer(vbox1) |
---|
[6fb01b6] | 114 | |
---|
[d7d143b0] | 115 | self.Centre() |
---|
| 116 | self.Show(True) |
---|
[925a30e] | 117 | |
---|
[9181512] | 118 | def OnButtonClicked(self, event): |
---|
| 119 | """ |
---|
[389c991] | 120 | Function to diplay Model html page related to the hyperlinktext selected |
---|
[9181512] | 121 | """ |
---|
[18cdddb] | 122 | |
---|
| 123 | self.rhelp.LoadPage(self.path) |
---|
[925a30e] | 124 | |
---|
[b92884a] | 125 | def OnLinkClicked(self, event): |
---|
| 126 | """ |
---|
[5062bbf] | 127 | Function to diplay html page related to the hyperlinktext selected |
---|
[b92884a] | 128 | """ |
---|
| 129 | link= event.GetLinkInfo().GetHref() |
---|
[389c991] | 130 | |
---|
[c0a30a24] | 131 | self.rhelp.LoadPage(os.path.abspath(link)) |
---|
[389c991] | 132 | |
---|
[5062bbf] | 133 | """ |
---|
| 134 | Example: :: |
---|
[b92884a] | 135 | |
---|
[5062bbf] | 136 | class ViewApp(wx.App): |
---|
| 137 | def OnInit(self): |
---|
| 138 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
| 139 | frame.Show(True) |
---|
| 140 | self.SetTopWindow(frame) |
---|
| 141 | |
---|
| 142 | return True |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | if __name__ == "__main__": |
---|
[2268d10] | 146 | app = ViewApp(0) |
---|
[5062bbf] | 147 | app.MainLoop() |
---|
| 148 | |
---|
| 149 | """ |
---|