[Twisted-Python] Twisted and Qt5

Hi, I have a question and a general guidance request on handling Qt and Twisted together. This is nearly as much a Qt question as it is a Twisted one, so I apologise in advance if this is off–topic. To give a little bit of a background, I am building a desktop GUI application which I am coding using Python and Javascript. The back–end is Python, which makes use of SQLAlchemy, Twisted and several other Python frameworks. The GUI is in Qt, currently linked to Python with PyQt, but I will probably replace it with PySide before release. I am using Qt to draw a QtWebkit frame, in which I run Angular JS to serve up my visual interface, plus a host of other data presentation logic. Which is, it turns out, quite an impasse, because if I use Qt4, the GUI of my application renders in … 12 seconds. Qt5 and its version of QtWebkit loads the same thing in 300 milliseconds. I am therefore forced to use Qt5. This is how I end up with an application where both Twisted and Qt5 are essential requirements. Now, my questions are these: 1) I know there is a Qt4 reactor (which I managed to get to work and pass the twisted test suite) for Twisted. Is there such a thing for Qt5? Is it planned? 2) In the case it's not, are there any alternatives to having a Qt5 reactor? My Twisted knowledge is still woefully inexact (I'm still reading the Twisted book), so I am not very well versed on alternative ways to accomplish this. The one way I can see is to modify the Twisted Qt4 reactor to work with Qt5, but I have almost no knowledge of C++, so this seems far–fetched. This is my only unsolved question about my application— a project of love and learning rather than a commercial one—so if I can figure this out, I'll be well on my way. In case there is nothing to be done about this and a Qt5 reactor is an imperative, I would be willing to finance this to the best of my ability; I'm a student, but I can try to pay whatever is needed to have this reactor done, open sourced—and added to Twisted core, if desired. If there is such a project on its way, I can be a tester. If nobody is interested I would be very happy if you could give me a lead on how to make my own reactor; if I succeed I can release it as open source. Likely I am not a programmer good enough to make that happen, though! Qt is pretty much the only decent GUI framework in existence and almost the only way to have a Python application with a web–stack GUI, which is one of the most popular ways desktop applications are designed these days. If you know of another way to run Webkit as a Python GUI, I'd love to hear that too, but to the extent of my research this looks impossible without Qt. Thanks! Best, Burak

On 07/20/2013 08:04 AM, Burak Nehbit wrote:
1) I know there is a Qt4 reactor <https://github.com/ghtdak/qtreactor> (which I managed to get to work and pass the twisted test suite) for Twisted. Is there such a thing for Qt5? Is it planned?
Have the Qt APIs changed enough that you can't just use the qt4 reactor with qt5?

There are significant changes in the signalling mechanisms in Qt5, but I have not tried yet. I'll try quite soon and return with my findings, but with the little knowledge I have, I would say it might be unlikely that it works without modification. — Sent from my phone On Sat, Jul 20, 2013 at 3:46 PM, Itamar Turner-Trauring <itamar@itamarst.org> wrote:
On 07/20/2013 08:04 AM, Burak Nehbit wrote:
1) I know there is a Qt4 reactor <https://github.com/ghtdak/qtreactor> (which I managed to get to work and pass the twisted test suite) for Twisted. Is there such a thing for Qt5? Is it planned?
Have the Qt APIs changed enough that you can't just use the qt4 reactor with qt5? _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

On Jul 20, 2013, at 5:04 AM, Burak Nehbit <burak@nehbit.net> wrote:
Is there such a thing for Qt5? Is it planned?
Well, it sounds like you're planning it, so, I guess so :). I doubt that anyone on this list has plans to do it (or there would already be work qt5 work done in the qt reactor repository) but there are plenty of people (myself included) who would be very happy to help you learn enough about Twisted to do it yourself. And, honestly, if you're motivated to do it it's probably *not* a huge amount of effort to update the implementation. Feel free to ask any questions you have on this list. In the meanwhile though, maybe you could report a bug to Nokia or Trolltech or whoever runs Qt development right now that they should stop gratuitously breaking interfaces between versions? We've had (at least one) major rewrite of the Qt reactor for every version of Qt, which seem to come out relatively frequently. Nothing about the nature of event loops or sockets has changed sufficiently in the meanwhile to justify the constant re-work that Qt seems to require from us. -glyph

I have been experimenting with porting qt4reactor to qt5, and I have some progress to share. It seems that the PyQt API that was being used in qt4reactor was deprecated, so I have converted the calls to the new version API and it seems it mostly works.. Except one thing: Traceback (most recent call last): File "sampleguiclient_twisted.py", line 132, in <module> from twisted.internet import reactor AttributeError: 'function' object has no attribute '__pyqtSignature__' I could not get past this error. I have prepared an example with a test case where you can see the error for yourself, and it can be reached here: https://dl.dropbox.com/s/4asklib8yuvm5ru/index.html This bunch of python files assume you have Qt5 installed, but otherwise free of dependencies. Any guesses on what's going on? Best, Burak On Jul 23, 2013, at 12:43 AM, Glyph <glyph@twistedmatrix.com> wrote:
On Jul 20, 2013, at 5:04 AM, Burak Nehbit <burak@nehbit.net> wrote:
Is there such a thing for Qt5? Is it planned?
Well, it sounds like you're planning it, so, I guess so :).
I doubt that anyone on this list has plans to do it (or there would already be work qt5 work done in the qt reactor repository) but there are plenty of people (myself included) who would be very happy to help you learn enough about Twisted to do it yourself. And, honestly, if you're motivated to do it it's probably *not* a huge amount of effort to update the implementation. Feel free to ask any questions you have on this list.
In the meanwhile though, maybe you could report a bug to Nokia or Trolltech or whoever runs Qt development right now that they should stop gratuitously breaking interfaces between versions? We've had (at least one) major rewrite of the Qt reactor for every version of Qt, which seem to come out relatively frequently. Nothing about the nature of event loops or sockets has changed sufficiently in the meanwhile to justify the constant re-work that Qt seems to require from us.
-glyph
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More good news. I have confirmed that the reason of this failure was my using of an unstable version of PyQt5. With the stable version of PyQt5, Qt 5.0.2 and the current Twisted stable, trial suite passes— or rather it fails with the same errors the default reactor fails: FAILED (skips=2025, expectedFailures=11, errors=1, successes=6578) The default twisted reactor goes through the suite in 61 seconds, qt5reactor in 66 seconds. Pretty good. You can find the qt5 reactor here: https://dl.dropbox.com/s/r285g4bo8jb4of9/index.html If I have more time, I'll package this reactor and put it on GitHub, but I am not sure if I have the (moral) right to—the only thing I did was to change four or five lines, after all. Mind that PySide does not yet support Qt5, so I have removed PySide imports. It seems that they have no plans to support Qt5 for at least through the next year. Hope it helps someone! Best, Burak On Aug 9, 2013, at 7:55 PM, Burak Nehbit <burak@nehbit.net> wrote:
I have been experimenting with porting qt4reactor to qt5, and I have some progress to share. It seems that the PyQt API that was being used in qt4reactor was deprecated, so I have converted the calls to the new version API and it seems it mostly works.. Except one thing:
Traceback (most recent call last): File "sampleguiclient_twisted.py", line 132, in <module> from twisted.internet import reactor AttributeError: 'function' object has no attribute '__pyqtSignature__'
I could not get past this error. I have prepared an example with a test case where you can see the error for yourself, and it can be reached here:
https://dl.dropbox.com/s/4asklib8yuvm5ru/index.html
This bunch of python files assume you have Qt5 installed, but otherwise free of dependencies.
Any guesses on what's going on?
Best, Burak
On Jul 23, 2013, at 12:43 AM, Glyph <glyph@twistedmatrix.com> wrote:
On Jul 20, 2013, at 5:04 AM, Burak Nehbit <burak@nehbit.net> wrote:
Is there such a thing for Qt5? Is it planned?
Well, it sounds like you're planning it, so, I guess so :).
I doubt that anyone on this list has plans to do it (or there would already be work qt5 work done in the qt reactor repository) but there are plenty of people (myself included) who would be very happy to help you learn enough about Twisted to do it yourself. And, honestly, if you're motivated to do it it's probably *not* a huge amount of effort to update the implementation. Feel free to ask any questions you have on this list.
In the meanwhile though, maybe you could report a bug to Nokia or Trolltech or whoever runs Qt development right now that they should stop gratuitously breaking interfaces between versions? We've had (at least one) major rewrite of the Qt reactor for every version of Qt, which seem to come out relatively frequently. Nothing about the nature of event loops or sockets has changed sufficiently in the meanwhile to justify the constant re-work that Qt seems to require from us.
-glyph
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

If I have more time, I'll package this reactor and put it on GitHub, but I am not sure if I have the (moral) right to—the only thing I did was to change four or five lines, after all.
You could instead put together a patch file - or even just document the exact changes you made - and file an issue in the Twisted issue tracker to have your changes included in Twisted proper. Shell

Qt4Reactor (my original file) is not a part of current Twisted due to licensing incompatibilities between Twisted and PyQt. The same licensing restrictions should also apply to my edited version, since I have no right to change the license on my own. I am using this as my base: https://github.com/ghtdak/qtreactor Best, Burak On Aug 10, 2013, at 5:10 PM, Shell <cam.turn@gmail.com> wrote:
If I have more time, I'll package this reactor and put it on GitHub, but I am not sure if I have the (moral) right to—the only thing I did was to change four or five lines, after all.
You could instead put together a patch file - or even just document the exact changes you made - and file an issue in the Twisted issue tracker to have your changes included in Twisted proper.
Shell
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

On Sat, Aug 10, 2013 at 10:14 AM, Burak Nehbit <burak@nehbit.net> wrote:
Qt4Reactor (my original file) is not a part of current Twisted due to licensing incompatibilities between Twisted and PyQt. The same licensing restrictions should also apply to my edited version, since I have no right to change the license on my own. I am using this as my base: https://github.com/ghtdak/qtreactor
May be you could create a pull request to this repository?
-- Mikhail Terekhov

These changes use the new API and may possibly prevent the current reactor in the repo from correctly functioning under Qt4. I have no Qt4 / PyQt / Twisted environment ready, so if anybody has that available I would love to hear the results. — Sent from my phone On Sun, Aug 11, 2013 at 7:11 PM, Mikhail Terekhov <termim@gmail.com> wrote:
On Sat, Aug 10, 2013 at 10:14 AM, Burak Nehbit <burak@nehbit.net> wrote:
Qt4Reactor (my original file) is not a part of current Twisted due to licensing incompatibilities between Twisted and PyQt. The same licensing restrictions should also apply to my edited version, since I have no right to change the license on my own. I am using this as my base: https://github.com/ghtdak/qtreactor
May be you could create a pull request to this repository? -- Mikhail Terekhov

On Sun, Aug 11, 2013 at 12:24 PM, Burak Nehbit <burak@nehbit.net> wrote:
These changes use the new API and may possibly prevent the current reactor in the repo from correctly functioning under Qt4. I have no Qt4 / PyQt / Twisted environment ready, so if anybody has that available I would love to hear the results. —
What about creating a branch? -- Mikhail Terekhov
participants (5)
-
Burak Nehbit
-
Glyph
-
Itamar Turner-Trauring
-
Mikhail Terekhov
-
Shell