Reputation: 2787
my files
messi_fan.py
barcelona_fan.html
jq.js
in same directory.
messi_fan.py
f = open('barcelona_fan.html', 'r')
html = f.read()
f.close()
self.webView = QWebView()
self.webView.setHtml(html, baseUrl=QUrl('http://local'))
self.webView.show()
barcelona_fan.html
<script type="text/javascript" src = "jq.js"></script>
my problem is jquery not loading in Qwebview. if i use like this in barcelona_fan.html
<script type="text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
everything would work. but i want to load .js file from local.How can i do this?
Upvotes: 1
Views: 1701
Reputation: 73
Let the baseUrl look to the local directory:
path = "c:\\foo\\bar"
self.webView.setHtml(html, baseUrl = QUrl().fromLocalFile(path))
BTW: if needed, don't forget:
self.webView.settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True)
Upvotes: 2