source: sasview/src/sas/perspectives/fitting/help_panel.py @ 79492222

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 79492222 was 79492222, checked in by krzywon, 9 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1"""
2    Help dialog
3"""
4import wx
5import wx.html as html
6from wx.lib.splitter import MultiSplitterWindow
7import os
8from wx.lib.scrolledpanel import ScrolledPanel
9
10class HelpPanel(ScrolledPanel):
11    def __init__(self, parent, **kwargs):
12        ScrolledPanel.__init__(self, parent, **kwargs)
13        self.SetupScrolling()
14
15
16class HelpWindow(wx.Frame):
17    """
18    """
19    def __init__(self, parent, id, title='Fitting Help', pageToOpen=None, size=(850, 540)):
20        wx.Frame.__init__(self, parent, id, title, size=size)
21        """
22        contains help info
23        """
24        self.Show(False)
25        self.SetTitle(title) 
26        from sas.perspectives.fitting import get_data_path as fit_path
27        fitting_path = fit_path(media='media')
28        ico_file = os.path.join(fitting_path, 'ball.ico')
29        if os.path.isfile(ico_file):
30            self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO))
31        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
32        self.rpanel = wx.Panel(splitter, -1)
33        self.lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN)
34       
35        vbox = wx.BoxSizer(wx.VERTICAL)
36        header = wx.Panel(self.rpanel, -1)
37        header.SetBackgroundColour('#6666FF')
38        header.SetForegroundColour('WHITE')
39        hbox = wx.BoxSizer(wx.HORIZONTAL)
40        st = wx.StaticText(header, -1, 'Contents', (5, 5))
41        font = st.GetFont()
42        font.SetPointSize(10)
43        st.SetFont(font)
44        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
45        header.SetSizer(hbox)
46        vbox.Add(header, 0, wx.EXPAND)
47       
48        vboxl= wx.BoxSizer(wx.VERTICAL)
49        headerl = wx.Panel(self.lpanel, -1, size=(-1, 20))
50       
51        headerl.SetBackgroundColour('#6666FF')
52        headerl.SetForegroundColour('WHITE')
53        hboxl = wx.BoxSizer(wx.HORIZONTAL)
54        lst = wx.StaticText(headerl, -1, 'Menu', (5, 5))
55        fontl = lst.GetFont()
56        fontl.SetPointSize(10)
57        lst.SetFont(fontl)
58        hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
59        headerl.SetSizer(hboxl)
60        vboxl.Add(headerl, 0, wx.EXPAND)
61        self.lhelp = html.HtmlWindow(self.lpanel, -1, style=wx.NO_BORDER)
62        self.rhelp = html.HtmlWindow(self.rpanel, -1, style=wx.NO_BORDER, 
63                                     size=(500, -1))
64
65        # get the media path
66        if pageToOpen != None:
67            path = os.path.dirname(pageToOpen)
68        else:
69            from sas.models import get_data_path as model_path
70            # Get models help model_function path
71            path = model_path(media='media')
72
73        self.path = os.path.join(path, "model_functions.html")
74        self.path_pd = os.path.join(path, "pd_help.html")
75        self.path_sm = os.path.join(path, "smear_computation.html")
76        self.path_mag = os.path.join(path, "polar_mag_help.html")
77       
78        _html_file = [("load_data_help.html", "Load a File"),
79                      ("single_fit_help.html", "Single Fit"),
80                      ("simultaneous_fit_help.html", "Simultaneous Fit"),
81                      ("batch_help.html", "Batch Fit"),
82                      ("model_use_help.html", "Model Selection"),
83                      ("category_manager_help.html", "Model Category Manager"),
84                      ("%s" % self.path, "Model Functions"),
85                      ("model_editor_help.html", "Custom Model Editor"),
86                      ("%s" % self.path_pd, "Polydispersion Distributions"),
87                      ("%s" % self.path_sm, "Smear Computation"),
88                      ("%s" % self.path_mag, "Polarization/Magnetic Scattering"),
89                      ("key_help.html", "Key Combination"),
90                      ("status_bar_help.html", "Status Bar Help"),
91                      ]
92 
93        page1 = """<html>
94            <body>
95             <p>Select topic on Menu</p>
96            </body>
97            </html>"""
98           
99        page = """<html>
100            <body>
101            <ul>
102            """
103           
104        for (p, title) in _html_file:
105            pp = os.path.join(fitting_path, p)
106            page += """<li><a href ="%s" target="showframe">%s</a><br></li>""" % (pp, title)
107        page += """</ul>
108                    </body>
109                    </html>
110                """
111               
112        self.rhelp.SetPage(page1)
113        self.lhelp.SetPage(page)
114        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked )
115       
116        #open the help frame a the current page
117        if  pageToOpen != None:
118            self.rhelp.LoadPage(str(pageToOpen))
119           
120        vbox.Add(self.rhelp, 1, wx.EXPAND)
121        vboxl.Add(self.lhelp, 1, wx.EXPAND)
122        self.rpanel.SetSizer(vbox)
123        self.lpanel.SetSizer(vboxl)
124        self.lpanel.SetFocus()
125       
126        vbox1 = wx.BoxSizer(wx.HORIZONTAL)
127        vbox1.Add(splitter, 1, wx.EXPAND)
128        splitter.AppendWindow(self.lpanel, 200)
129        splitter.AppendWindow(self.rpanel)
130        self.SetSizer(vbox1)
131
132        self.splitter = splitter
133        self.Centre()
134        self.Bind(wx.EVT_SIZE, self.on_Size)
135       
136    def OnButtonClicked(self, event):
137        """
138        Function to diplay Model html page related to the hyperlinktext selected
139        """
140        self.rhelp.LoadPage(self.path)
141       
142    def OnLinkClicked(self, event):
143        """
144        Function to diplay html page related to the hyperlinktext selected
145        """
146        link = event.GetLinkInfo().GetHref()
147       
148        self.rhelp.LoadPage(os.path.abspath(link))
149       
150    def on_Size(self, event):
151        """
152        Recover the scroll position On Size
153        """
154        pos = self.rhelp.GetScrollPos(wx.VERTICAL)
155        size = self.GetClientSize()
156        self.splitter.SetSize(size)
157        self.rhelp.Show(False)
158        self.rhelp.ScrollLines(pos)
159        self.rhelp.Show(True)
Note: See TracBrowser for help on using the repository browser.