<div class="gmail_quote">On 7 June 2010 02:37, Alex Hall <span dir="ltr">&lt;<a href="mailto:mehgcap@gmail.com">mehgcap@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">
</div>I am not sure how else to explain it. I want to loop until the value<br>
of a variable changes, but while that loop is taking place, the user<br>
should be able to perform actions set up in a wx.AcceleratorTable.<br>
Looping, though, causes Windows to tell me that python.exe is not<br>
responding, so I have to close the entire thing. I guess I am looking<br>
for a &quot;listener&quot;, which will sit in the background and only perform an<br>
action when it detects a certain thing. In this case, a listener to<br>
watch for a variable to turn from False to True, then to act when it<br>
sees that change.<br></blockquote></div><br>Notwithstanding what everyone else have said I&#39;ll add the following for what it&#39;s worth:<br><br>You need to do some research into how GUI systems typically work, particularly the message queue and each applications &quot;magic&quot; and hidden message processing loop etc.  Basically in a GUI app there&#39;s a hidden loop that continually checks for messages (calls) to your application and dispatches those calls to the handlers defined in your application.  However, if your handlers do not complete quickly, then while they run, control obviously does not return to this loop again, and consequently no further events can/will be processed by your app.  Some OS&#39;s flag up applications which do not process their event queues for a while as &quot;not responding&quot; or similar.  <br>
<br>However, in most windowing systems there&#39;s a way to process pending messages that have built up in the queue without actually returning from the handler that you&#39;re in.  In Delphi the call is &quot;Application.ProcessMessages&quot;, in VB it&#39;s &quot;DoEvents&quot;.  In WxPython it&#39;s Yield().  (You can google each of those to see the same issue in different languages/platforms if you like, it might be instructive.)  <br>
<br>So bottom line, in theory you can call Yield() in your loop and you should be OK -- your app should suddenly be responsive again even while in the loop.   This type of solution is however the more &quot;cheap and dirty&quot; alternative and can introduce it&#39;s own set of problems and downsides.  (What if for example another call/message is processed to the same event handler from which you called Yield() alrady?  The point is you may open yourself up to re-entrancy issues if you&#39;re not careful.  Also if the loop is very tight you might end-up consuming a lot of CPU doing nothing, so a sleep() type call might also be advisable in the loop to prevent spending more time calling Yield() than doing anything else. )<br>
<br>Anyway, I&#39;ve done a quick google and the following page seems to be a good discussion of the above thoughts:<br><a href="http://wiki.wxpython.org/LongRunningTasks">http://wiki.wxpython.org/LongRunningTasks</a><br>
<br>HTH,<br><br>Walter<br>