[PyQt] Waiting For A Signal

Robert Kent rob at gulon.co.uk
Wed May 21 15:08:58 BST 2014


Hi Marc,

Thanks for your reply. I am actually quite well versed in threading and it
is precisely this that I am trying to avoid. The 2nd event loop and signal
waiter mechanisms both work beautifully in C++, I was just wondering what
the difference was in PyQt and if it was avoidable. I can actually achieve
my aim using callbacks rather than threads, but its not as neat. I'm aware
that I essentially want to have my cake and eat it, I was just wondering if
anyone else had encountered and/or come up with a solution.

Thanks again, Rob

From:  Marc Thomas <jazzyflute at gmail.com>
Date:  Wednesday, 21 May 2014 14:47
To:  Robert Kent <rob at gulon.co.uk>
Cc:  pyqt <pyqt at riverbankcomputing.com>
Subject:  Re: [PyQt] Waiting For A Signal

Hey Robert,

You are going to want to loop into threading. Essentially what is happening
right now is that your main thread (GUI thread) is kicking off a process
that runs for a while. While that process is happening, nothing else can
happen. If you multi-thread your application, you can kick that process off
in the background thus not locking up your GUI.

Here is an example of PyQt4 multi-threading I have written:
http://pastebin.com/YFASwSb9
This is good tutorial explaining the different components of multi-threading
with PyQT: http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/

Hope this helps!



On Tue, May 20, 2014 at 12:30 PM, Robert Kent <rob at gulon.co.uk> wrote:
> Hi All,
> 
> As the subject line of suggests, I want to wait for a signal to be emitted
> (block essentially), but I want to do this whilst keeping the GUI alive. I
> have tried both creating my own event loop and re-implelmenting libqxt's
> QxtSignalWaiter, but my signal of choice is never caught until after either
> the event loop has quit of the signal waiter has stopped waiting. I'm guessing
> this is something to do with the way the event loop is executed in PyQt (or
> I'm doing something very wrong ;o). Has anyone had any success or experience
> with doing this in Python (I've done it before in C++).
> 
> Thanks, Rob
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt



-- 
Website <http://mathomaste.ch>    :   Google+
<https://plus.google.com/u/0/103260909450809151378/about>    :   Twitter
<https://twitter.com/mathomastech>    :   GitHub
<https://github.com/mathomastech>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140521/c477b344/attachment.html>


More information about the PyQt mailing list