[PyQt] Qt WebChannel JavaScript API

Robert Kent rob at gulon.co.uk
Wed Aug 26 10:55:47 BST 2015


Hi,

I actually looked at the ‘standalone’ example a little while ago and created a PyQt5 version (attached ’standalone.tar'), however, there seems to be a bug with the QWebChannelAbstractTransport.messageReceived signal and its arguments in that the specification says it expects a dictionary, but that raises a TypeError as follows:

Traceback (most recent call last):
  File "standalone.py", line 35, in textMessageReceived
    self.messageReceived.emit(message.object(), self)
TypeError: QWebChannelAbstractTransport.messageReceived[dict-of-str-QJsonValue, QWebChannelAbstractTransport].emit(): argument 1 has unexpected type ‘dict'

This is using Qt5.4/PyQt5.4 however so it may have been fixed by now, if not maybe Phil could have a look?

Anyways, hopefully the attached example may help with anyone wanting to use this module. Beware that the version of qwebchannel.js included only works with <=Qt5.4, you will need to get the newer version if you are using Qt5.5.

Hope this helps, 

Rob



> On 25 Aug 2015, at 15:42, Florian Bruhin <me at the-compiler.org> wrote:
> 
> Hey!
> 
> * Dustin Falgout <dustin at falgout.us> [2015-08-25 08:38:21 -0500]:
>> I'm hoping to use the Qt Webchannel Javascript API in an application
>> I am working on. It is possible using PyQt5? The only documentation
>> I can find online is the C implementation.[1] If anyone could point
>> me in the right direction I'd really appreciate it. 
> 
>> [1] http://doc.qt.io/qt-5/qtwebchannel-javascript.html
> 
> That only seems to talk about the Javascript side of things, not C++.
> 
> Have you tried using something like the standalone example[1] and
> translating that into Python, to see what's missing?
> 
> [1] http://doc.qt.io/qt-5/qtwebchannel-standalone-example.html
> 
> I'm not sure if PyQt wraps all needed things, but I'd be glad to use
> QtWebChannel in the future as well. Maybe someone else can say more.
> 
>> -- Dustin FalgoutFreelance Web Developer
>> E-mail: dustin at falgout.usGoogle/Skype: dustinfalgoutFreenode IRC: #antergos
>> Web Development Services
> 
> PS: Your signature seems a bit broken (missing spaces) in the
> plaintext version of your mail.
> 
> Florian
> 
> -- 
> http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
>   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
>         I love long mails! | http://email.is-not-s.ms/
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150826/1ef07cc4/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: standalone.tar
Type: application/x-tar
Size: 25088 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150826/1ef07cc4/attachment-0001.tar>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150826/1ef07cc4/attachment-0003.html>


More information about the PyQt mailing list