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