source: sasview/src/sas/guiframe/documentation_window.py @ fa6a8d1

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 fa6a8d1 was 573e7034, checked in by Peter Parker, 10 years ago

Merge branch 'master' of github.com:SasView/sasview

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[a4340d1]1import os
2import logging
[c3437260]3import wx
4from wx import Frame
[a4340d1]5import webbrowser
[c3437260]6wx_supports_html2 = float(wx.__version__[:3]) >= 2.9
7if wx_supports_html2:
8    import wx.html2 as html
9else:
10    import wx.html as html
[9afc543]11from gui_manager import get_app_dir
12
13PATH_APP = get_app_dir() 
[c3437260]14
15class DocumentationWindow(Frame):
[69032d4]16    def __init__(self, parent, id, path, title, size=(850, 540)):
[c3437260]17        Frame.__init__(self, parent, id, title, size=size)
18
[a4340d1]19        SPHINX_DOC_ENV = "SASVIEW_DOC_PATH"
20        if SPHINX_DOC_ENV in os.environ:
21            docs_path = os.path.join(os.environ[SPHINX_DOC_ENV])
22        else:
[9afc543]23            # For the installer, docs are in a top-level directory.  We're not
24            # bothering to worry about docs when running using the old
25            # (non - run.py) way.
26            docs_path = os.path.join(PATH_APP, "doc")
[a4340d1]27
[9afc543]28        if not os.path.exists(docs_path):
[a4340d1]29            logging.error("Could not find Sphinx documentation at %s \
30            -- has it been built?", docs_path)
31
32        elif wx_supports_html2:
[c3437260]33            # Complete HTML/CSS support!
34            self.view = html.WebView.New(self)
[a4340d1]35            self.view.LoadURL("file://" + docs_path + '\\' + path)
36            self.Show()
37        else: 
38            #For cases that do not build against current version dependency
39            # Wx 3.0 we provide a webbrowser call - this is particularly for
40            #Red hat used at SNS for which Wx 3.0 is not available.  This
41            #does not deal with issue of math in docs of course.
42
43            webbrowser.open_new_tab("file:///" + docs_path + "/" + path)
[69032d4]44            print ("file:///" + docs_path + "/" + path)
[a4340d1]45
46 
Note: See TracBrowser for help on using the repository browser.