[PyQt] Processing signals from a called method while the method executes

alanm me at alandmoore.com
Fri Jul 2 14:38:53 BST 2010


On Friday 02 July 2010 1:17:06 am Andreas Pakulat wrote:
> 
> Don't block the event-loop with your processor. The signals are
> delivered as you expect, but the widget is not redrawn with that
> message. The reason is that your processing blocks the Qt event loop and
> hence no painting is done.
> 
> Possible options to not block the event loop that long would be to use a
> QTimer to schedule each part of your processing after the next
> event-loop run. The other option would be moving the processing into a
> separate thread, you should only go this route after making familiar
> with multi-threading though.
> 
> Andreas

Thanks for the reply.  I don't think I understand, though.  I read in the 
QTimer documentation where I can do a zero-millisecond timer to schedule 
things after the next event run, but changing

sleep(10)

To:

QTimer.singleShot(0, lambda: sleep(10))

Seemed like it should do that.  It doesn't.  Apparently the 
processor.process() method is still blocking.   Where am I going wrong here?


More information about the PyQt mailing list