I have an application which has several functions that are
somewhat long-running (e.g. 10 to 15 seconds).
The application has a console window that displays various messages. The console is a wx.richtext.RichTextCtrl. I would like to do something along the lines
of:
Display message “Starting to do thing…”
Do thing
Display message “Done with thing”
but the messages don’t appear until the thing is all
done. I tried putting “Do
thing” and the final message in a separate function, called with
wx.CallAfter, hoping this would give the first message a chance to appear, but that didn’t help. I
could put “Do thing” in a different thread, but I don’t really want
the user interface to be usable during thing, I only want the message to appear
in the console.
Can anyone suggest a way to make this work?
Thanks,
Matthew
Cody wrote:
> Using threads would probably be the best way. But if you don't want to
> use them you could add a call to wx.YieldIfNeeded() after calling to
> add the text to the control. That will give the event loop a chance to
> process so the screen can be redrawn to show the text.
>
> Cody
>
> Thanks! That's exactly what I needed. It lets the message appear, and doesn't give the user access to the rest of the user interface. Actually, I wound up using the similar wx.SafeYield, although the effect was the same.
> Matthew
···
On Sun, Nov 16, 2008 at 1:12 PM, Matthew Cahn matthew.cahn@gmail.com wrote: