source: sasview/fittingview/src/sans/perspectives/fitting/help_panel.py @ 9f4f8f4

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 9f4f8f4 was c0a30a24, checked in by Gervaise Alina <gervyh@…>, 13 years ago

make sure media folder is found

  • Property mode set to 100644
File size: 4.9 KB
Line 
1#!/usr/bin/python
2
3import wx
4import wx.html as html
5from wx.lib.splitter import MultiSplitterWindow
6import os
7
8
9class HelpWindow(wx.Frame):
10    """
11    """
12    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None):
13        wx.Frame.__init__(self, parent, id, title, size=(850, 530))
14        """
15        contains help info
16        """
17     
18        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
19        rpanel = wx.Panel(splitter, -1)
20        lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN)
21       
22        vbox = wx.BoxSizer(wx.VERTICAL)
23        header = wx.Panel(rpanel, -1)
24        header.SetBackgroundColour('#6666FF')
25        header.SetForegroundColour('WHITE')
26        hbox = wx.BoxSizer(wx.HORIZONTAL)
27        st = wx.StaticText(header, -1, 'Contents', (5, 5))
28        font = st.GetFont()
29        font.SetPointSize(10)
30        st.SetFont(font)
31        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
32        header.SetSizer(hbox)
33        vbox.Add(header, 0, wx.EXPAND)
34       
35        vboxl= wx.BoxSizer(wx.VERTICAL)
36        headerl = wx.Panel(lpanel, -1, size=(-1, 20))
37       
38        headerl.SetBackgroundColour('#6666FF')
39        headerl.SetForegroundColour('WHITE')
40        hboxl = wx.BoxSizer(wx.HORIZONTAL)
41        lst = wx.StaticText(headerl, -1, 'Menu', (5, 5))
42        fontl = lst.GetFont()
43        fontl.SetPointSize(10)
44        lst.SetFont(fontl)
45        hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
46        headerl.SetSizer(hboxl)
47        vboxl.Add(headerl, 0, wx.EXPAND)
48        self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER)
49        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1))
50
51        import sans.models as models 
52        # get the media path
53        path = models.get_data_path(media='media')
54        self.path = os.path.join(path,"model_functions.html")
55        self.path_pd = os.path.join(path,"pd_help.html")
56        self.path_sm = os.path.join(path,"smear_computation.html")
57        import sans.perspectives.fitting as fitting
58       
59        fitting_path = fitting.get_data_path(media='media')
60       
61        _html_file = {"status_bar_help.html":"Status Bar Help",
62                      "load_data_help.html":"Load a File",
63                      "simultaneous_fit_help.html":"Simultaneous Fit",
64                      "single_fit_help.html":"Single Fit",
65                      "model_use_help.html":"Model Selection",
66                      "key_help.html":"Key Combination",
67                      }
68
69                   
70        page1="""<html>
71            <body>
72             <p>Select topic on Menu</p>
73            </body>
74            </html>"""
75        page="""<html>
76            <body>
77            <ul>
78            """
79        for p, title in _html_file.iteritems():
80            pp = os.path.join(fitting_path, p)
81            page += """<li><a href ="%s" target="showframe">%s</a><br></li>""" % (pp, title)
82         
83        page += """
84            <li><a href ="%s" target="showframe">Model Functions</a><br></li>
85            <li><a href ="%s" target="showframe">Polydispersion Distributions</a><br></li>
86            <li><a href ="%s" target="showframe">Smear Computation</a><br></li>
87            </ul>
88            </body>
89            </html>""" % (self.path, self.path_pd, self.path_sm)
90       
91        self.rhelp.SetPage(page1)
92        self.lhelp.SetPage(page)
93        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked )
94       
95        #open the help frame a the current page
96        if  pageToOpen!= None:
97            self.rhelp.LoadPage(str( pageToOpen))
98           
99        vbox.Add(self.rhelp,1, wx.EXPAND)
100        vboxl.Add(self.lhelp, 1, wx.EXPAND)
101        rpanel.SetSizer(vbox)
102        lpanel.SetSizer(vboxl)
103        lpanel.SetFocus()
104       
105        vbox1 = wx.BoxSizer(wx.HORIZONTAL)
106        vbox1.Add(splitter,1,wx.EXPAND)
107        splitter.AppendWindow(lpanel, 200)
108        splitter.AppendWindow(rpanel)
109        self.SetSizer(vbox1)
110       
111        self.Centre()
112        self.Show(True)
113       
114    def OnButtonClicked(self, event):
115        """
116        Function to diplay Model html page related to the hyperlinktext selected
117        """
118       
119        self.rhelp.LoadPage(self.path)
120       
121    def OnLinkClicked(self, event):
122        """
123        Function to diplay html page related to the hyperlinktext selected
124        """
125        link= event.GetLinkInfo().GetHref()
126       
127        self.rhelp.LoadPage(os.path.abspath(link))
128       
129"""
130Example: ::
131
132    class ViewApp(wx.App):
133        def OnInit(self):
134            frame = HelpWindow(None, -1, 'HelpWindow')   
135            frame.Show(True)
136            self.SetTopWindow(frame)
137           
138            return True
139           
140   
141    if __name__ == "__main__":
142    app = ViewApp(0)
143    app.MainLoop() 
144
145"""   
Note: See TracBrowser for help on using the repository browser.