source: sasview/sansview/perspectives/fitting/help_panel.py @ 7c488ef5

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 7c488ef5 was 23ccf07, checked in by Gervaise Alina <gervyh@…>, 13 years ago

find the path for media

  • Property mode set to 100644
File size: 6.7 KB
RevLine 
[d7d143b0]1#!/usr/bin/python
[5062bbf]2
[d7d143b0]3import wx
4import wx.html as html
[f8b79d6]5from wx.lib.splitter import MultiSplitterWindow
[d292959]6import os
[23ccf07]7import sys
[925a30e]8
[23ccf07]9   
[2268d10]10class HelpWindow(wx.Frame):
[5062bbf]11    """
12    """
[4faf4ba]13    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None):
[389c991]14        wx.Frame.__init__(self, parent, id, title, size=(850, 530))
[925a30e]15        """
[5062bbf]16        contains help info
[925a30e]17        """
[23ccf07]18        path = os.path.dirname(__file__)
19        temp_path = os.path.join(path,'images')
20        ico_file = os.path.join(temp_path,'ball.ico')
21        if os.path.isfile(ico_file):
22            self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO))
23        else:
24            temp_path = os.path.join(os.getcwd(),'images')
25            ico_file = os.path.join(temp_path,'ball.ico')
26            if os.path.isfile(ico_file):
27                self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO))
28            else:
29                ico_file = os.path.join(os.path.dirname(os.path.sys.path[0]),
30                             'images', 'ball.ico')
31                if os.path.isfile(ico_file):
32                    self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO))
33                   
[f8b79d6]34        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
35        rpanel = wx.Panel(splitter, -1)
36        lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN)
[d7d143b0]37       
38        vbox = wx.BoxSizer(wx.VERTICAL)
[6fb01b6]39        header = wx.Panel(rpanel, -1)
[d7d143b0]40        header.SetBackgroundColour('#6666FF')
41        header.SetForegroundColour('WHITE')
42        hbox = wx.BoxSizer(wx.HORIZONTAL)
[2268d10]43        st = wx.StaticText(header, -1, 'Contents', (5, 5))
[d7d143b0]44        font = st.GetFont()
45        font.SetPointSize(10)
46        st.SetFont(font)
47        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
48        header.SetSizer(hbox)
49        vbox.Add(header, 0, wx.EXPAND)
50       
[b92884a]51        vboxl= wx.BoxSizer(wx.VERTICAL)
52        headerl = wx.Panel(lpanel, -1, size=(-1, 20))
[d292959]53       
[b92884a]54        headerl.SetBackgroundColour('#6666FF')
55        headerl.SetForegroundColour('WHITE')
56        hboxl = wx.BoxSizer(wx.HORIZONTAL)
[2268d10]57        lst = wx.StaticText(headerl, -1, 'Menu', (5, 5))
[b92884a]58        fontl = lst.GetFont()
59        fontl.SetPointSize(10)
60        lst.SetFont(fontl)
61        hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
62        headerl.SetSizer(hboxl)
63        vboxl.Add(headerl, 0, wx.EXPAND)
64        self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER)
[6fb01b6]65        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1))
[18cdddb]66
67        import sans.models as models 
68        # get the media path
69        path = models.get_data_path(media='media')
[23ccf07]70        if not os.path.isdir(path):
71             path = os.path.dirname(os.path.sys.path[0])
[18cdddb]72        self.path = os.path.join(path,"model_functions.html")
[389c991]73        self.path_pd = os.path.join(path,"pd_help.html")
[384647dc]74        self.path_sm = os.path.join(path,"smear_computation.html")
[18cdddb]75                   
[2268d10]76        page1="""<html>
77            <body>
78             <p>Select topic on Menu</p>
79            </body>
80            </html>"""
[23ccf07]81       
82        if not os.path.isfile(os.path.join(path, "change_scale_help.html")):
83            path = os.path.join(os.path.dirname(os.path.sys.path[0]), 'media')
84        page = """<html>
[b92884a]85            <body>
86            <ul>
[23ccf07]87            <li><a href ="%s" target ="showframe">Change Scale</a><br></li>
88            """ % str(os.path.join(path, "change_scale_help.html"))
89        page += """
90            <li><a href ="%s" target ="showframe">Graph Help</a><br></li>
91            """ % str(os.path.join(path,  "reset_Graph_help.html"))
92        page += """
93            <li><a href ="%s" target ="showframe">Status Bar Help</a><br></li>
94            """ % str(os.path.join(path,  "status_bar_help.html"))
95        page += """
96            <li><a href ="%s" target ="showframe">Load a File</a><br></li>
97            """ % str(os.path.join(path, "load_data_help.html"))
98        page += """
99            <li><a href ="%s"
100            target ="showframe">Simultaneous Fit</a><br></li>
101            """ % str(os.path.join(path, "simultaneous_fit_help.html"))
102        page += """
103            <li><a href ="%s"
104            target ="showframe">Single Fit</a><br></li>
105            """ % str(os.path.join(path,  "single_fit_help.html"))
106        page += """
107            <li><a href ="%s"
108            target ="showframe">Visualize Model</a><br></li>
109            """ % str(os.path.join(path, "model_use_help.html"))
110        page += """
111            <li><a href ="%s"
112            target ="showframe">Data Averaging</a><br></li>
113            """ % str(os.path.join(path,  "averaging_help.html"))
114        page += """
[18cdddb]115            <li><a href ="%s" target ="showframe">Model Functions</a><br></li>
[23ccf07]116            """ % str(self.path)
117        page += """<li><a href ="%s" target ="showframe">
118                Polydispersion Distributions</a><br></li>
119                """ % str(self.path_pd)
120        page += """
[384647dc]121            <li><a href ="%s" target ="showframe">Smear Computation</a><br></li>
[23ccf07]122            """ % str(self.path_sm)
123        page += """<li><a href ="%s"
124        target ="showframe">Key Combination</a><br></li>
[b92884a]125            </ul>
126            </body>
[23ccf07]127            </html>""" % str(os.path.join(path,  "key_help.html"))
[18cdddb]128       
[2268d10]129        self.rhelp.SetPage(page1)
[b92884a]130        self.lhelp.SetPage(page)
131        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked )
[9181512]132       
[4faf4ba]133        #open the help frame a the current page
134        if  pageToOpen!= None:
135            self.rhelp.LoadPage(str( pageToOpen))
[9181512]136           
[dcd330b]137        vbox.Add(self.rhelp,1, wx.EXPAND)
[b92884a]138        vboxl.Add(self.lhelp, 1, wx.EXPAND)
[d7d143b0]139        rpanel.SetSizer(vbox)
[b92884a]140        lpanel.SetSizer(vboxl)
141        lpanel.SetFocus()
[d7d143b0]142       
[f8b79d6]143        vbox1 = wx.BoxSizer(wx.HORIZONTAL)
144        vbox1.Add(splitter,1,wx.EXPAND)
145        splitter.AppendWindow(lpanel, 200)
146        splitter.AppendWindow(rpanel)
[d7d143b0]147        self.SetSizer(vbox1)
[6fb01b6]148       
[d7d143b0]149        self.Centre()
150        self.Show(True)
[925a30e]151       
[9181512]152    def OnButtonClicked(self, event):
153        """
[389c991]154        Function to diplay Model html page related to the hyperlinktext selected
[9181512]155        """
[18cdddb]156       
157        self.rhelp.LoadPage(self.path)
[925a30e]158       
[b92884a]159    def OnLinkClicked(self, event):
160        """
[5062bbf]161        Function to diplay html page related to the hyperlinktext selected
[b92884a]162        """
163        link= event.GetLinkInfo().GetHref()
[389c991]164       
[b92884a]165        self.rhelp.LoadPage(link)
[389c991]166       
[5062bbf]167"""
168Example: ::
[b92884a]169
[5062bbf]170    class ViewApp(wx.App):
171        def OnInit(self):
172            frame = HelpWindow(None, -1, 'HelpWindow')   
173            frame.Show(True)
174            self.SetTopWindow(frame)
175           
176            return True
177           
178   
179    if __name__ == "__main__":
[2268d10]180    app = ViewApp(0)
[5062bbf]181    app.MainLoop() 
182
183"""   
Note: See TracBrowser for help on using the repository browser.