Changeset c4e3215 in sasmodels
- Timestamp:
- Apr 4, 2017 5:26:07 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3a45c2c, 01e551a
- Parents:
- f68e2a5
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r6cff473 rc4e3215 1150 1150 show html docs for the model 1151 1151 """ 1152 import wx # type: ignore 1153 from .generate import view_html_from_info 1154 app = wx.App() if wx.GetApp() is None else None 1155 view_html_from_info(opts['def'][0]) 1156 if app: app.MainLoop() 1157 1152 import os 1153 from .generate import make_html 1154 from . import rst2html 1155 1156 info = opts['def'][0] 1157 html = make_html(info) 1158 path = os.path.dirname(info.filename) 1159 url = "file://"+path.replace("\\","/")[2:]+"/" 1160 rst2html.view_html_qtapp(html, url) 1158 1161 1159 1162 def explore(opts): -
sasmodels/generate.py
r1e7b0db0 rc4e3215 928 928 from . import rst2html 929 929 url = "file://"+dirname(info.filename)+"/" 930 rst2html. wxview(make_html(info), url=url)930 rst2html.view_html(make_html(info), url=url) 931 931 932 932 def demo_time(): -
sasmodels/rst2html.py
r0890871 rc4e3215 29 29 from docutils.writers.html4css1 import HTMLTranslator 30 30 from docutils.nodes import SkipNode 31 32 def wxview(html, url="", size=(850, 540)):33 import wx34 from wx.html2 import WebView35 frame = wx.Frame(None, -1, size=size)36 view = WebView.New(frame)37 view.SetPage(html, url)38 frame.Show()39 return frame40 41 def view_rst(filename):42 from os.path import expanduser43 with open(expanduser(filename)) as fid:44 rst = fid.read()45 html = rst2html(rst)46 wxview(html)47 31 48 32 def rst2html(rst, part="whole", math_output="mathjax"): … … 155 139 assert replace_dollar(u"a (again $in parens$) a") == u"a (again :math:`in parens`) a" 156 140 157 def view_rst_app(filename): 141 def load_rst_as_html(filename): 142 from os.path import expanduser 143 with open(expanduser(filename)) as fid: 144 rst = fid.read() 145 html = rst2html(rst) 146 return html 147 148 def wxview(html, url="", size=(850, 540)): 149 import wx 150 from wx.html2 import WebView 151 frame = wx.Frame(None, -1, size=size) 152 view = WebView.New(frame) 153 view.SetPage(html, url) 154 frame.Show() 155 return frame 156 157 def qtview(html, url=""): 158 try: 159 from PyQt5.QtWebKitWidgets import QWebView 160 from PyQt5.QtCore import QUrl 161 except ImportError: 162 from PyQt4.QtWebkit import QWebView 163 from PyQt4.QtCore import QUrl 164 helpView = QWebView() 165 helpView.setHtml(html, QUrl(url)) 166 helpView.show() 167 return helpView 168 169 def view_html_wxapp(html, url=""): 158 170 import wx # type: ignore 159 171 app = wx.App() 160 view_rst(filename)172 frame = wxview(html, url) 161 173 app.MainLoop() 162 174 175 def view_html_qtapp(html, url=""): 176 import sys 177 try: 178 from PyQt5.QtWidgets import QApplication 179 except ImportError: 180 from PyQt4.QtGui import QApplication 181 app = QApplication([]) 182 frame = qtview(html, url) 183 sys.exit(app.exec_()) 184 185 def view_rst_app(filename, qt=False): 186 import os 187 html = load_rst_as_html(filename) 188 url="file://"+os.path.abspath(filename)+"/" 189 if qt: 190 view_html_qtapp(html, url) 191 else: 192 view_html_wxapp(html, url) 163 193 164 194 if __name__ == "__main__": 165 195 import sys 166 view_rst_app(sys.argv[1] )196 view_rst_app(sys.argv[1], qt=True) 167 197
Note: See TracChangeset
for help on using the changeset viewer.