[PyQt] Selective "processEvents"

Andreas Pakulat apaku at gmx.de
Fri Feb 4 21:54:45 GMT 2011


On 05.02.11 02:05:12, r wrote:
> Is it possible to specify a list of events that are to be processed by
> the Qt main loop?
> 
> I have an application where:
> 1. QTimer.singleShot(0, targetFunction) is used to schedule processing
> of some deferred computations.
> 2. In some other part of the application I have a console emulator
> which intercepts sys.stdout.write and redirects any text printed to it
> to a QTextView component.
> 
> In order to update the QTextView contents I was using a processEvents
> function in my sys.stdout.write implementation, but then I found it
> interferes badly with the singleShot scheduling (basically it forces
> the deferred computations when something is printed on the console).

Why are you doing this? Whats blocking the event loop? You need to
unblock the event-loop so that its running to get the updates to happen
(and your single-shot timer too). There's no way to only execute
painting events, you can only choose to exclude user-input and/or
socket-notifiers. So you need to fix your app to not block the qt event
loop, this does not necessarily mean that you need threading though.

Andreas

-- 
You are a fluke of the universe; you have no right to be here.


More information about the PyQt mailing list