source: sasview/calculatorview/perspectives/calculator/help_panel.py @ 65265c0b

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 65265c0b was 65265c0b, checked in by Jae Cho <jhjcho@…>, 14 years ago

added slit cal help

  • Property mode set to 100644
File size: 5.9 KB
Line 
1#!/usr/bin/python
2import wx
3import wx.html as html
4from wx.lib.splitter import MultiSplitterWindow
5import os
6def 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   
29class HelpDialog(wx.Dialog):
30    def __init__(self, parent, id):
31     
32        wx.Dialog.__init__(self, parent, id, size=(400, 420))
33        self.SetTitle("Calculator 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")
49
50        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
51        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
52        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)       
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()
60
61class HelpWindow(wx.Frame):
62    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None):
63        wx.Frame.__init__(self, parent, id, title, size=(700, 450))
64        """
65             contains help info
66        """
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)
71       
72        vbox = wx.BoxSizer(wx.VERTICAL)
73        header = wx.Panel(rpanel, -1)
74        header.SetBackgroundColour('#6666FF')
75        header.SetForegroundColour('WHITE')
76        hbox = wx.BoxSizer(wx.HORIZONTAL)
77        st = wx.StaticText(header, -1, 'Contents', (5, 5))
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       
85        vboxl= wx.BoxSizer(wx.VERTICAL)
86        headerl = wx.Panel(lpanel, -1, size=(-1, 20))
87       
88        headerl.SetBackgroundColour('#6666FF')
89        headerl.SetForegroundColour('WHITE')
90        hboxl = wx.BoxSizer(wx.HORIZONTAL)
91        lst = wx.StaticText(headerl, -1, 'Menu', (5, 5))
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)
99        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, 
100                                     size=(500,-1))
101        import sans.perspectives.calculator as calculator
102        path = calculator.get_data_path(media='media')
103        self.path= os.path.join(path,"sld_calculator_help.html")
104       
105        self.rhelp.LoadPage(self.path)
106        page1="""<html>
107            <body>
108             <p>Select topic on Menu</p>
109            </body>
110            </html>"""
111        #self.rhelp.SetPage(page1)
112        page="""<html>
113            <body>
114            <ul>
115            <li><a href =%s target ="showframe">SLD Calculator</a><br></li>
116            <li><a href ="media/slit_calculator_help.html" target ="showframe">Slit Size Calculator</a><br></li>
117            </ul>
118            </body>
119            </html>"""%self.path
120
121        self.lhelp.SetPage(page)
122        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked )
123       
124        vbox.Add(self.rhelp,1, wx.EXPAND)
125        vboxl.Add(self.lhelp, 1, wx.EXPAND)
126        rpanel.SetSizer(vbox)
127        lpanel.SetSizer(vboxl)
128        lpanel.SetFocus()
129       
130        vbox1 = wx.BoxSizer(wx.HORIZONTAL)
131        vbox1.Add(splitter,1,wx.EXPAND)
132        splitter.AppendWindow(lpanel, 200)
133        splitter.AppendWindow(rpanel)
134        self.SetSizer(vbox1)
135       
136        self.Centre()
137        self.Show(True)
138       
139       
140    def OnLinkClicked(self, event):
141        """
142            Function to diplay html page related to the hyperlinktext selected
143        """
144        #self.rhelp.LoadPage(self.path)
145        link= event.GetLinkInfo().GetHref()
146        self.rhelp.LoadPage(link)
147class ViewApp(wx.App):
148    def OnInit(self):
149        frame = HelpWindow(None, -1, 'HelpWindow')   
150        frame.Show(True)
151        self.SetTopWindow(frame)
152       
153        return True
154       
155
156if __name__ == "__main__": 
157    app = ViewApp(0)
158    app.MainLoop()     
Note: See TracBrowser for help on using the repository browser.