source: sasview/calculatorview/perspectives/calculator/help_panel.py @ 74b1770

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

added kiessig fringe calculator and fixed slit length by ½ as our definition of slit length

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