Last active
November 10, 2016 10:59
-
-
Save janpipek/820e0546b416df452cbb556d5b302408 to your computer and use it in GitHub Desktop.
SImplest Qt + Webkit + MathJax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import QtCore, QtGui, QtWebKit | |
import sys | |
app = QtGui.QApplication(sys.argv) | |
# Define content | |
head = """ | |
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']]}});</script> | |
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"></script>""" | |
body = "$x + 4$" | |
html = """ | |
<!DOCTYPE html> | |
<html> | |
<head>{0}</head> | |
<body>{1}<body> | |
</html> | |
""".format(head, body) | |
with open("output.html", "w") as output: | |
output.write(html) | |
wk = QtWebKit.QWebView() | |
wk.setHtml(html) | |
wk.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment