我使用PyQt4的(4.11版本)和Python2.7Html頁面無法在PyQt的正確顯示Qwebview
我想PyQt的圖形用戶界面嵌入HTML頁面使用Qwebview,從plotly離線生成 的HTML,簡單地包含條形圖圖所示: bar chart
self.webView = QtWebKit.QWebView(self.centralwidget)
self..webView.setUrl(QtCore.QUrl('file:///D:/Anaconda/Lib/site-packages/PyQt4/my-graph.html'))
然而,在QwebView HTML顯示什麼,而它可以在Windows瀏覽器中正確顯示plotly條形圖
我還TR組捲到地址設定爲plotly網站 self.load(QtCore.QUrl('https://plot.ly/python/axes/'))
,結果發現,只有plotly圖像無法正常顯示 text and images display well
當我生成html由谷歌圖表
然後我試圖設置以下出現同樣的問題參數,但它仍然不起作用
self.webView = QtWebKit.QWebView(self.centralwidget)
s=self.webView.settings()
s.setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True)
s.setAttribute(QtWebKit.QWebSettings.JavascriptEnabled, True)
s.setAttribute(QtWebKit.QWebSettings.JavascriptCanOpenWindows, True)
s.setAttribute(QtWebKit.QWebSettings.JavascriptCanAccessClipboard, True)
s.setAttribute(QtWebKit.QWebSettings.JavaEnabled, True)
s.setAttribute(QtWebKit.QWebSettings.AutoLoadImages, True)
s.setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True)
s.setAttribute(QtWebKit.QWebSettings.LocalStorageEnabled, True)
s.setAttribute(QtWebKit.QWebSettings.SpatialNavigationEnabled, True)
s.setAttribute(QtWebKit.QWebSettings.LocalContentCanAccessRemoteUrls, True)
s.setAttribute(QtWebKit.QWebSettings.LocalContentCanAccessFileUrls, True)
我現在不知道,有沒有人可以解決這個問題?
我已經改變PyQt4的到PyQt5,QtWebKit的到QtWebEngine ,雖然它需要Python 3,我需要修改我的代碼很多,現在它工作正常。非常感謝 –
看到Python 2也只是正式維護了四年,切換到Python 3可能也不是一個壞主意;) –