4 ms·
You don’t have to use Qt’s event loop: you can just call app.processEvents() when it suits you.
by marmaduke 9y ago
You don’t have to use Qt’s event loop: you can just call app.processEvents() when it suits you.
- geofft 9y agoSure, but if you don't have events of your own to process, either you're constantly calling processEvents() and spinning the CPU, or you're in a loop that does so every second, which is both high-latency and inefficient (and bad for battery life). You generally want to process an event when it suits the event, not when it suits you :-) It looks like this is done by subclassing QAbstractEventDispatcher and filling out virtual functions registerSocketNotifier(), registerTimer(), etc. I suppose you could do this for asyncio/Twisted, but I'd prefer to import something where someone has done this for me and is accepting bug reports from the community, because this is the sort of thing that's made of edge cases that are hard to notice in testing.
- infinite8s 9y agoI've used variations of qt4reactor (https://pypi.python.org/pypi/qt4reactor/1.6 https://pypi.python.org/pypi/qt4reactor/1.6) to integrate Twisted with PyQt apps. It usually works pretty well for desktop apps (I used it to create an ssh tunnel using twisted conch for a desktop database visualization too).