Joubert Lucas
Joubert Lucas

Reputation: 163

What to Use Instead of QWebEngineView for PyQt 5.6 with Anaconda 3

I am using plotly to generate HTML code I then use QWebEngineView to view. This worked fine before I tried to go over to Anaconda 3. Based on some searching, this is because Anaconda's PyQt distribution is behind the actual current distribution (which I used to originally write the code). What would be the correct way to make a widget that I can set the HTML of in QWebKit, which is what Anaconda's PyQt comes with? It's also okay to say that I shouldn't be using Anaconda. I prefer it primarily for the libraries it comes with (I'm not using the enterprise version) but could also get them for the Python 3.6 I'm already using.

Upvotes: 0

Views: 939

Answers (1)

user3419537
user3419537

Reputation: 5000

QtWebKit provides the QWebView widget, that can be used in much the same way as QWebEngineView

from PyQt5 import QtWidgets, QtWebKitWidgets

html = '''<body>
            <b>Hello world!</b>
          </body>'''

app = QtWidgets.QApplication([])
webview = QtWebKitWidgets.QWebView()
webview.setHtml(html)
webview.show()
app.exec_()

You could also take a look at cefpython for a Chromium based browser widget that can be embedded in a PyQt GUI regardless of version. It's a little heavyweight, but I have found it to be much faster than QtWebkit. I'm not sure if it's available for Anaconda however.

Upvotes: 1

Related Questions