Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
View HTML content in Python with PySide
"""
Placed into public domain by
anatoly techtonik <techtonik@gmail.com>
Show HTML in GUI window through PyQt4/PySide.
[ ] position window at the center of the screen
(right now it is middle bottom)
[ ] implement lazy loading for PyQt4/PySide
"""
import sys
try:
from PySide import QtGui, QtWebKit
except ImportError:
try:
from PyQt4 import QtGui, QtWebKit
except ImportError:
sys.stderr.write("WebView requires PySide or PyQt4 for GUI window")
def viewhtml(html):
app = QtGui.QApplication([])
view = QtWebKit.QWebView()
view.setHtml(html)
view.show()
app.exec_()
def viewurl(url):
app = QtGui.QApplication([])
view = QtWebKit.QWebView()
view.load(url)
view.show()
app.exec_()
viewhtml('''<b>WebView Public Gist</b>''')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.