Skip to content

Instantly share code, notes, and snippets.

@oglops
Last active Jul 2, 2017
Embed
What would you like to do?
qwebview load() does not need to load js and css manually
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>gifplayer</title>
<base href="http://rubentd.com"></base>
<link rel="stylesheet" type="text/css" href="bower_components/jquery.gifplayer/dist/gifplayer.css"></link>
<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="bower_components/jquery.gifplayer/dist/jquery.gifplayer.js"></script>
<script>
$(document).ready(function(){
$('.gif').gifplayer();
});
</script>
</head>
<body>
<img class="gif" data-src="img/banana.gif" src="img/banana.png">
</body>
</html>
import sys
from PyQt4.QtWebKit import QWebView, QWebInspector, QWebSettings
from PyQt4.QtGui import QApplication, QDialog, QHBoxLayout
from PyQt4.QtCore import QUrl
class Dialog(QDialog):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
layout = QHBoxLayout()
self.browser = QWebView()
self.browser.page().settings().setAttribute(
QWebSettings.DeveloperExtrasEnabled, True)
self.inspector = QWebInspector(self)
self.inspector.setPage(self.browser.page())
layout.addWidget(self.browser)
layout.addWidget(self.inspector)
self.setLayout(layout)
self.browser.load(QUrl('gifplayer.html'))
self.resize(1400, 800)
self.browser.page().setContentEditable(True)
app = QApplication(sys.argv)
dialog = Dialog()
dialog.show()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment