source: sasview/sansview/perspectives/fitting/helpPanel.py @ 00c3aac

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 00c3aac was 925a30e, checked in by Gervaise Alina <gervyh@…>, 15 years ago

comments added to class

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