QtWebEngineWidgets in Maya2018

QtWebEngineWidgets in Maya2018

Anonymous
Not applicable
1,535 Views
2 Replies
Message 1 of 3

QtWebEngineWidgets in Maya2018

Anonymous
Not applicable

Hello,

 

Has anyone been trying to use PySide2's QtWebEngineWidgets that ships with Maya2018?

 

There seems to be bits missing when comparing it with the Qt5.9 docs. For example:

 

QWebEnginePage should have the following method from looking at the docs 

runJavaScript(const QString &scriptSource, FunctorOrLambda resultCallback)

Which I would assume would translate across into PySide2 as something along the lines of:

runJavaScript(scriptSource, resultCallback)

However in PySide2 within Maya when I try running an example:

from PySide2.QtWebEngineWidgets import *
from PySide2.QtCore import *

view = QWebEngineView()
url = 'https://www.google.co.uk/'
view.load(QUrl(url))
view.show()

code = "document.getElementById('lst-ib')['value']"
def callback(value):
    print(value)

view.page().runJavaScript(code, callback)

I get the following error:

# Error: TypeError: file <maya console> line 13: runJavaScript() takes exactly one argument (2 given) # 

 

Has this function not been ported across fully? There are other attributes missing such as: (and probably a lot more)

QWebEnginePage.toPlainText(callback)
QWebEnginePage.toHtml(callback)

Is this an Autodesk issue that they aren't shipping a fully working QtWebEngineWidgets or is the PySide2 port still incomplete?

 

 

I need to use the runJavaScript function that takes a callback so I can use the result of my js code in my widget. Unlike the old QtWebKit, QtWebEngine in an asynchronous library, so relies on the use of callbacks to do anything that queries the page, that's why QWebElement was dropped (which is what I would have used otherwise).

 

Any help would be much appreciated, thanks!

0 Likes
1,536 Views
2 Replies
Replies (2)
Message 2 of 3

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

It looks like a PySide2's issue. According to error message, it only takes one argument. I think because there is no overload feature in Python thus some overloaded functions won't be generated directly.

 

If you call it with only code parameter, it works fine on Maya 2018 Update 1.

 

Yours,

Li

0 Likes
Message 3 of 3

Anonymous
Not applicable

That's a shame.

 

Yes calling with just the code param will run, but then there is no way to retrieve the result of the js code? I can successfully alter the webpage but I can't read from it.

 

My goal is to be able to show a webpage with input fields and grab the input within Maya. Is anyone familiar with PySide2's QtWebEngineWidgets, is this possible at this stage?

 

0 Likes