[d7d143b0] | 1 | #!/usr/bin/python |
---|
| 2 | import wx |
---|
| 3 | import wx.html as html |
---|
[f8b79d6] | 4 | from wx.lib.splitter import MultiSplitterWindow |
---|
[d292959] | 5 | import os |
---|
[b92884a] | 6 | def help(): |
---|
| 7 | """ |
---|
| 8 | Provide general online help text |
---|
| 9 | Future work: extend this function to allow topic selection |
---|
| 10 | """ |
---|
| 11 | info_txt = "The inversion approach is based on Moore, J. Appl. Cryst. (1980) 13, 168-175.\n\n" |
---|
| 12 | info_txt += "P(r) is set to be equal to an expansion of base functions of the type " |
---|
| 13 | info_txt += "phi_n(r) = 2*r*sin(pi*n*r/D_max). The coefficient of each base functions " |
---|
| 14 | info_txt += "in the expansion is found by performing a least square fit with the " |
---|
| 15 | info_txt += "following fit function:\n\n" |
---|
| 16 | info_txt += "chi**2 = sum_i[ I_meas(q_i) - I_th(q_i) ]**2/error**2 + Reg_term\n\n" |
---|
| 17 | info_txt += "where I_meas(q) is the measured scattering intensity and I_th(q) is " |
---|
| 18 | info_txt += "the prediction from the Fourier transform of the P(r) expansion. " |
---|
| 19 | info_txt += "The Reg_term term is a regularization term set to the second derivative " |
---|
| 20 | info_txt += "d**2P(r)/dr**2 integrated over r. It is used to produce a smooth P(r) output.\n\n" |
---|
| 21 | info_txt += "The following are user inputs:\n\n" |
---|
| 22 | info_txt += " - Number of terms: the number of base functions in the P(r) expansion.\n\n" |
---|
| 23 | info_txt += " - Regularization constant: a multiplicative constant to set the size of " |
---|
| 24 | info_txt += "the regularization term.\n\n" |
---|
| 25 | info_txt += " - Maximum distance: the maximum distance between any two points in the system.\n" |
---|
| 26 | |
---|
| 27 | return info_txt |
---|
| 28 | |
---|
| 29 | class HelpDialog(wx.Dialog): |
---|
| 30 | def __init__(self, parent, id): |
---|
| 31 | |
---|
| 32 | wx.Dialog.__init__(self, parent, id, size=(400, 420)) |
---|
| 33 | self.SetTitle("P(r) help") |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 37 | |
---|
| 38 | explanation = help() |
---|
| 39 | |
---|
| 40 | label_explain = wx.StaticText(self, -1, explanation, size=(350,320)) |
---|
| 41 | |
---|
| 42 | vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15) |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | static_line = wx.StaticLine(self, -1) |
---|
| 46 | vbox.Add(static_line, 0, wx.EXPAND, 0) |
---|
| 47 | |
---|
| 48 | button_OK = wx.Button(self, wx.ID_OK, "OK") |
---|
[925a30e] | 49 | |
---|
[b92884a] | 50 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 51 | sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[925a30e] | 52 | sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
[b92884a] | 53 | vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
| 54 | |
---|
| 55 | self.SetSizer(vbox) |
---|
| 56 | self.SetAutoLayout(True) |
---|
| 57 | |
---|
| 58 | self.Layout() |
---|
| 59 | self.Centre() |
---|
[d7d143b0] | 60 | |
---|
[2268d10] | 61 | class HelpWindow(wx.Frame): |
---|
[4faf4ba] | 62 | def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None): |
---|
[1c779b6] | 63 | wx.Frame.__init__(self, parent, id, title, size=(850, 500)) |
---|
[925a30e] | 64 | """ |
---|
| 65 | contains help info |
---|
| 66 | """ |
---|
[f8b79d6] | 67 | |
---|
| 68 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
| 69 | rpanel = wx.Panel(splitter, -1) |
---|
| 70 | lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN) |
---|
[d7d143b0] | 71 | |
---|
| 72 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
[6fb01b6] | 73 | header = wx.Panel(rpanel, -1) |
---|
[d7d143b0] | 74 | header.SetBackgroundColour('#6666FF') |
---|
| 75 | header.SetForegroundColour('WHITE') |
---|
| 76 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
[2268d10] | 77 | st = wx.StaticText(header, -1, 'Contents', (5, 5)) |
---|
[d7d143b0] | 78 | font = st.GetFont() |
---|
| 79 | font.SetPointSize(10) |
---|
| 80 | st.SetFont(font) |
---|
| 81 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
| 82 | header.SetSizer(hbox) |
---|
| 83 | vbox.Add(header, 0, wx.EXPAND) |
---|
| 84 | |
---|
[b92884a] | 85 | vboxl= wx.BoxSizer(wx.VERTICAL) |
---|
| 86 | headerl = wx.Panel(lpanel, -1, size=(-1, 20)) |
---|
[d292959] | 87 | |
---|
[b92884a] | 88 | headerl.SetBackgroundColour('#6666FF') |
---|
| 89 | headerl.SetForegroundColour('WHITE') |
---|
| 90 | hboxl = wx.BoxSizer(wx.HORIZONTAL) |
---|
[2268d10] | 91 | lst = wx.StaticText(headerl, -1, 'Menu', (5, 5)) |
---|
[b92884a] | 92 | fontl = lst.GetFont() |
---|
| 93 | fontl.SetPointSize(10) |
---|
| 94 | lst.SetFont(fontl) |
---|
| 95 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
| 96 | headerl.SetSizer(hboxl) |
---|
| 97 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
| 98 | self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER) |
---|
[6fb01b6] | 99 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1)) |
---|
[2268d10] | 100 | page1="""<html> |
---|
| 101 | <body> |
---|
| 102 | <p>Select topic on Menu</p> |
---|
| 103 | </body> |
---|
| 104 | </html>""" |
---|
[b92884a] | 105 | page="""<html> |
---|
| 106 | <body> |
---|
| 107 | <ul> |
---|
[0df5d68] | 108 | <li><a href ="media/change_scale_help.html" target ="showframe">Change Scale</a><br></li> |
---|
[3244cbe1] | 109 | <li><a href ="media/reset_Graph_help.html" target ="showframe">Graph Help</a><br></li> |
---|
[0df5d68] | 110 | <li><a href ="media/status_bar_help.html" target ="showframe">Status Bar Help</a><br></li> |
---|
[3244cbe1] | 111 | <li><a href ="media/load_data_help.html" target ="showframe">Load a File</a><br></li> |
---|
| 112 | <li><a href ="media/simultaneous_fit_help.html" target ="showframe">Simultaneous Fit</a><br></li> |
---|
| 113 | <li><a href ="media/single_fit_help.html" target ="showframe">Single Fit</a><br></li> |
---|
| 114 | <li><a href ="media/model_use_help.html" target ="showframe">Visualize Model</a><br></li> |
---|
| 115 | <li><a href ="media/averaging_help.html" target ="showframe">Data Averaging</a><br></li> |
---|
| 116 | <li><a href ="media/model_functions.html" target ="showframe">Model Functions</a><br></li> |
---|
[b92884a] | 117 | </ul> |
---|
| 118 | </body> |
---|
| 119 | </html>""" |
---|
[2268d10] | 120 | self.rhelp.SetPage(page1) |
---|
[b92884a] | 121 | self.lhelp.SetPage(page) |
---|
| 122 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked ) |
---|
[9181512] | 123 | |
---|
[4faf4ba] | 124 | #open the help frame a the current page |
---|
| 125 | if pageToOpen!= None: |
---|
| 126 | self.rhelp.LoadPage(str( pageToOpen)) |
---|
[9181512] | 127 | |
---|
[dcd330b] | 128 | vbox.Add(self.rhelp,1, wx.EXPAND) |
---|
[b92884a] | 129 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
[d7d143b0] | 130 | rpanel.SetSizer(vbox) |
---|
[b92884a] | 131 | lpanel.SetSizer(vboxl) |
---|
| 132 | lpanel.SetFocus() |
---|
[d7d143b0] | 133 | |
---|
[f8b79d6] | 134 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 135 | vbox1.Add(splitter,1,wx.EXPAND) |
---|
| 136 | splitter.AppendWindow(lpanel, 200) |
---|
| 137 | splitter.AppendWindow(rpanel) |
---|
[d7d143b0] | 138 | self.SetSizer(vbox1) |
---|
[6fb01b6] | 139 | |
---|
[d7d143b0] | 140 | self.Centre() |
---|
| 141 | self.Show(True) |
---|
[925a30e] | 142 | |
---|
[9181512] | 143 | def OnButtonClicked(self, event): |
---|
| 144 | """ |
---|
| 145 | Function to diplay html page related to the hyperlinktext selected |
---|
| 146 | """ |
---|
[3244cbe1] | 147 | #link= "media/modelfunction.html" |
---|
| 148 | self.rhelp.LoadPage("media/modelfunction.html") |
---|
[925a30e] | 149 | |
---|
[b92884a] | 150 | def OnLinkClicked(self, event): |
---|
| 151 | """ |
---|
| 152 | Function to diplay html page related to the hyperlinktext selected |
---|
| 153 | """ |
---|
| 154 | link= event.GetLinkInfo().GetHref() |
---|
| 155 | self.rhelp.LoadPage(link) |
---|
| 156 | |
---|
[2268d10] | 157 | class ViewApp(wx.App): |
---|
[d7d143b0] | 158 | def OnInit(self): |
---|
[2268d10] | 159 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
| 160 | frame.Show(True) |
---|
| 161 | self.SetTopWindow(frame) |
---|
[d7d143b0] | 162 | |
---|
[2268d10] | 163 | return True |
---|
[d7d143b0] | 164 | |
---|
| 165 | |
---|
[2268d10] | 166 | if __name__ == "__main__": |
---|
| 167 | app = ViewApp(0) |
---|
| 168 | app.MainLoop() |
---|