[PyQt] wx.MilliSleep equivalent

Florian Bruhin me at the-compiler.org
Fri Sep 21 21:50:35 BST 2018

On Fri, Sep 21, 2018 at 03:51:15PM -0400, Tong Zhang wrote:
> Thanks Jones, QTimer.singleShot is a nice solution if you have nothing to do
> after this single line of code, or the right after consecutive code will be
> executed before the callback wrapped within singleShot method, which
> sometimes is not wanted.

You can continue doing whatever you want in the method connected to the
slot, though.

Ideally you could use Python's async support (native since 3.5, via
"yield" before that) with PyQt5.

Kyle Altendorf (altendky) was working on something like that here:
but that also involves Twisted. I'd like to have something like that but
only using native Qt stuff. Maybe one day... :D

> IMHO, qWait, qSleep and other functions, should be exposed somewhere at
> QTimer's reference page, such that, people like me can easily discover them,
> since normally the Qt users (not core Qt library developers) probably would
> not dive into QTest module to see if something is useful.

The problem with those is that they spin up a nested event loop while
waiting, which can lead to confusing issues. Probably okay in tests (and
there, you really don't want the test to finish before waiting is
finished), but problematic elsewhere.


https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180921/d94f915c/attachment.sig>

More information about the PyQt mailing list