source: sasview/src/sas/perspectives/calculator/help_panel.py @ 1ee0772

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 1ee0772 was b9a5f0e, checked in by krzywon, 10 years ago

90% complete with the conversion.

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[427fa87]1#!/usr/bin/python
[b0ab6cb]2"""
3Help panel for calculator
4"""
5import os
[427fa87]6import wx
7import wx.html as html
8from wx.lib.splitter import MultiSplitterWindow
[79492222]9import sas.perspectives.calculator as calculator
[427fa87]10
11
12class HelpWindow(wx.Frame):
[b0ab6cb]13    """
14    """
[318b5bbb]15    def __init__(self, parent, id=-1, title="Tool Help", pageToOpen=None, 
16                                                    size=(700, 450)):
17        wx.Frame.__init__(self, parent, id, title, size=size)
[427fa87]18        """
19             contains help info
20        """
[318b5bbb]21        self.SetTitle(title) 
[427fa87]22        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
23        rpanel = wx.Panel(splitter, -1)
[318b5bbb]24        self.lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN)
[427fa87]25       
26        vbox = wx.BoxSizer(wx.VERTICAL)
27        header = wx.Panel(rpanel, -1)
28        header.SetBackgroundColour('#6666FF')
29        header.SetForegroundColour('WHITE')
30        hbox = wx.BoxSizer(wx.HORIZONTAL)
31        st = wx.StaticText(header, -1, 'Contents', (5, 5))
32        font = st.GetFont()
33        font.SetPointSize(10)
34        st.SetFont(font)
35        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
36        header.SetSizer(hbox)
37        vbox.Add(header, 0, wx.EXPAND)
38       
[b0ab6cb]39        vboxl = wx.BoxSizer(wx.VERTICAL)
[318b5bbb]40        headerl = wx.Panel(self.lpanel, -1, size=(-1, 20))
[427fa87]41       
42        headerl.SetBackgroundColour('#6666FF')
43        headerl.SetForegroundColour('WHITE')
44        hboxl = wx.BoxSizer(wx.HORIZONTAL)
45        lst = wx.StaticText(headerl, -1, 'Menu', (5, 5))
46        fontl = lst.GetFont()
47        fontl.SetPointSize(10)
48        lst.SetFont(fontl)
49        hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
50        headerl.SetSizer(hboxl)
51        vboxl.Add(headerl, 0, wx.EXPAND)
[318b5bbb]52        self.lhelp = html.HtmlWindow(self.lpanel, -1, style=wx.NO_BORDER)
[427fa87]53        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, 
54                                     size=(500,-1))
[318b5bbb]55        if pageToOpen != None:
56            path = os.path.dirname(pageToOpen)
[b9a5f0e]57            self.path = os.path.join(path, "gen_sas_help.html")
[318b5bbb]58        else:
59            self.path = calculator.get_data_path(media='media')
[1c779b6]60       
[b0ab6cb]61        page1 = """<html>
[65265c0b]62            <body>
63             <p>Select topic on Menu</p>
64            </body>
65            </html>"""
[1c779b6]66        self.rhelp.SetPage(page1)
[b0ab6cb]67        page = """<html>
[427fa87]68            <body>
69            <ul>
[ce3feca]70            <li><a href ="data_operator_help.html"
71            target ="showframe">Data Operator</a><br></li>
[b0ab6cb]72            <li><a href ="sld_calculator_help.html"
73            target ="showframe">SLD Calculator</a><br></li>
[992b594]74            <li><a href ="density_calculator_help.html"
75            target ="showframe">Density Calculator</a><br></li>
[b0ab6cb]76            <li><a href ="slit_calculator_help.html"
77            target ="showframe">Slit Size Calculator</a><br></li>
78            <li><a href ="kiessig_calculator_help.html"
79            target ="showframe">Kiessig Thickness Calculator</a><br></li>
[44ad7f5]80            <li><a href ="resolution_calculator_help.html"
81            target ="showframe">Resolution Estimator</a><br></li>
[b9a5f0e]82            <li><a href ="gen_sas_help.html"
[318b5bbb]83            target ="showframe">Generic Scattering Calculator</a><br></li>
[40c84e4]84            <li><a href ="pycrust_help.html"
85            target ="showframe">Python Shell</a><br></li>
[3e001f9]86            <li><a href ="load_image_help.html"
87            target ="showframe">Image Viewer</a><br></li>
[427fa87]88            </ul>
89            </body>
[1c779b6]90            </html>"""
[65265c0b]91
[427fa87]92        self.lhelp.SetPage(page)
[b0ab6cb]93        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked)
[318b5bbb]94        if  pageToOpen != None:
95            self.rhelp.LoadPage(str(pageToOpen))
[b0ab6cb]96        vbox.Add(self.rhelp, 1, wx.EXPAND)
[427fa87]97        vboxl.Add(self.lhelp, 1, wx.EXPAND)
98        rpanel.SetSizer(vbox)
[318b5bbb]99        self.lpanel.SetSizer(vboxl)
100        self.lpanel.SetFocus()
[427fa87]101       
102        vbox1 = wx.BoxSizer(wx.HORIZONTAL)
[b0ab6cb]103        vbox1.Add(splitter, 1, wx.EXPAND)
[318b5bbb]104        splitter.AppendWindow(self.lpanel, 200)
[427fa87]105        splitter.AppendWindow(rpanel)
106        self.SetSizer(vbox1)
[318b5bbb]107       
108        self.splitter = splitter
[427fa87]109        self.Centre()
110        self.Show(True)
111       
112    def OnLinkClicked(self, event):
113        """
114            Function to diplay html page related to the hyperlinktext selected
115        """
[b0ab6cb]116        link = event.GetLinkInfo().GetHref()
117        link = os.path.join(self.path, link)
[65265c0b]118        self.rhelp.LoadPage(link)
[1c779b6]119       
[b0ab6cb]120       
[427fa87]121class ViewApp(wx.App):
122    def OnInit(self):
123        frame = HelpWindow(None, -1, 'HelpWindow')   
124        frame.Show(True)
125        self.SetTopWindow(frame)
126        return True
127       
128if __name__ == "__main__": 
129    app = ViewApp(0)
130    app.MainLoop()     
Note: See TracBrowser for help on using the repository browser.