[Twisted-Python] can QtWebKit fire a twisted deferred?

Glyph glyph at twistedmatrix.com
Wed May 6 20:22:41 MDT 2015


> On May 6, 2015, at 6:24 PM, Kevin Mcintyre <kebin70 at gmail.com> wrote:
> 
> That was pseudo code, I've been using qt5reactor to happy results.  All the same good to know on deferreds working in non-twisted code...

pseudo-code can sometimes illustrate a point, but when working with a real, large, complex API like Qt, it's often useful to have a http://sscce.org <http://sscce.org/> available to make sure the point you are demonstrating is the same as the point you think you're demonstrating :).

> My challenge is having only 2 hooks into the DOM - javaScriptAlert and javaScriptConfirm that ultimately with QtWebEngine aren't available.

When working with JS containers like this myself in the past, and needing to communicate with them from the container, I generally use eval as input:

http://doc.qt.io/qt-5/qwebenginepage.html#runJavaScript-2 <http://doc.qt.io/qt-5/qwebenginepage.html#runJavaScript-2>

and then console messages as output:

http://doc.qt.io/qt-5/qwebenginepage.html#javaScriptConsoleMessage <http://doc.qt.io/qt-5/qwebenginepage.html#javaScriptConsoleMessage>

You should be able to speak to the JS running inside your container by emitting specially-formatted console messages, and firing Deferreds in response to those.

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20150506/e542e32c/attachment-0002.html>


More information about the Twisted-Python mailing list