I've got s button even that triggers a fucntion that runs a simple test.
I would like the results of this test to change a test label elsewhere
on the gui. the test does this several times over its running time
(currently only a few seconds). However, because the button is waiting
for the function it called to return the GUI is frozen and the changes I
would like to make happen only the instant after the entire test is
complete. I would like to increase the complexity of the test to any
length of time so that the ongoing results would be more important.
There are a few different approaches:
1. Periodically call wxYield() in your long running function. This allows
events to be processed (including repainting labels,) and when there are no
more pending events the wxYield() will return. You'll want to be careful
with what events might happen durring the wxYield, specifically you'll
probably want to disable the button so the user can't start the whole thing
again.
2. Break your long running function into smaller chunks and execute them in
an idle handler (EVT_IDLE)
3. Run your long running function in a separate thread. When the thread
needs to update the GUI it can send an event to the main thread with
wxPostEvent. See the threads sample for an example.
ยทยทยท
--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!