Changeset d76c43a in sasview for src/sas/sasgui/guiframe/documentation_window.py
- Timestamp:
- Sep 20, 2017 4:39:48 PM (7 years ago)
- 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- fca1f50, 793713d
- Parents:
- ce0a245 (diff), f80b416e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Paul Kienzle <pkienzle@…> (09/20/17 16:39:48)
- git-committer:
- GitHub <noreply@…> (09/20/17 16:39:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/documentation_window.py
r6a455cd3 rf80b416e 16 16 import os 17 17 import logging 18 import wx19 18 import webbrowser 20 19 import urllib 21 20 import sys 22 21 22 import wx 23 try: 24 import wx.html2 as html 25 WX_SUPPORTS_HTML2 = True 26 except ImportError: 27 WX_SUPPORTS_HTML2 = False 28 29 from .gui_manager import get_app_dir 30 31 # Don't use wx html renderer on windows. 32 if os.name == 'nt': 33 WX_SUPPORTS_HTML2 = False 34 23 35 logger = logging.getLogger(__name__) 24 36 25 37 SPHINX_DOC_ENV = "SASVIEW_DOC_PATH" 26 WX_SUPPORTS_HTML2 = True27 try:28 import wx.html2 as html29 except:30 WX_SUPPORTS_HTML2 = False31 38 39 THREAD_STARTED = False 40 def start_documentation_server(doc_root, port): 41 import thread 42 global THREAD_STARTED 43 if not THREAD_STARTED: 44 thread.start_new_thread(_documentation_server, (doc_root, port)) 45 THREAD_STARTED = True 32 46 33 from gui_manager import get_app_dir 47 def _documentation_server(doc_root, port): 48 from SimpleHTTPServer import SimpleHTTPRequestHandler 49 from SocketServer import TCPServer 34 50 51 os.chdir(doc_root) 52 httpd = TCPServer(("127.0.0.1", port), SimpleHTTPRequestHandler, bind_and_activate=False) 53 httpd.allow_reuse_address = True 54 try: 55 httpd.server_bind() 56 httpd.server_activate() 57 httpd.serve_forever() 58 finally: 59 httpd.server_close() 35 60 36 61 class DocumentationWindow(wx.Frame): … … 70 95 #Note added June 21, 2015 PDB 71 96 file_path = os.path.join(docs_path, path) 72 url = "file:///" + urllib.quote(file_path, r'/\:')+ url_instruction 97 if path.startswith('http'): 98 url = path 99 elif not os.path.exists(file_path): 100 url = "index.html" 101 logger.error("Could not find Sphinx documentation at %s -- has it been built?", 102 file_path) 103 elif False: 104 start_documentation_server(docs_path, port=7999) 105 url = "http://127.0.0.1:7999/" + path.replace('\\', '/') + url_instruction 106 else: 107 url = "file:///" + urllib.quote(file_path, r'/\:')+ url_instruction 73 108 74 if not os.path.exists(file_path): 75 logger.error("Could not find Sphinx documentation at %s \ 76 -- has it been built?", file_path) 77 #Commenting following 5 lines, so default browser is forced 78 #This is due to CDN mathjax discontinuation of service, intenal help 79 #browser should be back with qt version 80 #Note added by Wojtek Potrzebowski, July 4th 2017 81 # elif WX_SUPPORTS_HTML2: 82 # # Complete HTML/CSS support! 83 # self.view = html.WebView.New(self) 84 # self.view.LoadURL(url) 85 # self.Show() 109 #logger.info("showing url " + url) 110 if WX_SUPPORTS_HTML2: 111 # Complete HTML/CSS support! 112 self.view = html.WebView.New(self) 113 self.view.LoadURL(url) 114 self.Bind(html.EVT_WEBVIEW_ERROR, self.OnError, self.view) 115 self.Show() 86 116 else: 87 117 logger.error("No html2 support, popping up a web browser") … … 92 122 webbrowser.open_new_tab(url) 93 123 124 def OnError(self, evt): 125 logger.error("%d: %s", evt.GetInt(), evt.GetString()) 126 94 127 def main(): 95 128 """ 96 129 main loop function if running alone for testing. 97 130 """ 131 url = "index.html" if len(sys.argv) <= 1 else sys.argv[1] 98 132 app = wx.App() 99 DocumentationWindow(None, -1, "index.html", "", "Documentation",)133 DocumentationWindow(None, -1, url, "", "Documentation",) 100 134 app.MainLoop() 101 135
Note: See TracChangeset
for help on using the changeset viewer.