Ignore:
Timestamp:
Feb 17, 2015 10:01:09 AM (9 years ago)
Author:
butler
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
0c4bca6
Parents:
296f290
Message:

Restructure the way the new help documentation gets displayed

1) Make the _onSphinxDocumentation a single line instatiation of
documentation_window passing only the location within the documentation
tree instead of the whol documentation path.

2) Put all the logic in documentation_window to check for 2.9 or higher

3) If lower than 2.9 go to same documentation but open with broswer (no
longer requires a connection)

4) Fix logging string so if the path is not found it fails but sends a
logging string to the log

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/guiframe/documentation_window.py

    r79492222 ra4340d1  
     1import os 
     2import logging 
    13import wx 
    24from wx import Frame 
    3  
     5import webbrowser 
    46wx_supports_html2 = float(wx.__version__[:3]) >= 2.9 
    57if wx_supports_html2: 
     
    810    import wx.html as html 
    911 
     12    
    1013class DocumentationWindow(Frame): 
    1114    def __init__(self, parent, id, path, title='Help', size=(850, 540)): 
    1215        Frame.__init__(self, parent, id, title, size=size) 
    1316 
    14         if wx_supports_html2: 
     17        SPHINX_DOC_ENV = "SASVIEW_DOC_PATH" 
     18        if SPHINX_DOC_ENV in os.environ: 
     19            docs_path = os.path.join(os.environ[SPHINX_DOC_ENV]) 
     20        else: 
     21            docs_path = os.path.join(PATH_APP, "..", "..", "doc") 
     22 
     23        if (not os.path.exists(docs_path)): 
     24            print "logging" 
     25            logging.error("Could not find Sphinx documentation at %s \ 
     26            -- has it been built?", docs_path) 
     27 
     28        elif wx_supports_html2: 
    1529            # Complete HTML/CSS support! 
    1630            self.view = html.WebView.New(self) 
    17             self.view.LoadURL("file://" + path) 
    18         else: 
    19             # This ain't gonna be pretty... 
    20             self.view = html.HtmlWindow(self, -1, style=wx.NO_BORDER) 
    21             self.view.LoadPage(path) 
     31            self.view.LoadURL("file://" + docs_path + '\\' + path) 
     32            self.Show() 
     33        else:  
     34            #For cases that do not build against current version dependency 
     35            # Wx 3.0 we provide a webbrowser call - this is particularly for  
     36            #Red hat used at SNS for which Wx 3.0 is not available.  This 
     37            #does not deal with issue of math in docs of course.  
     38 
     39            webbrowser.open_new_tab("file:///" + docs_path + "/" + path) 
     40 
     41  
Note: See TracChangeset for help on using the changeset viewer.