Hi. Following with previous doubts, I have some piece of code which tries to redirect stdoutput to a textcontrol inside a frame which appears when user clicks an option of the menu.
I have also added a button to the ‘floating’ frame in order to stop printing and continue printing data to the text control. The problem is that I can stop printing, but focus doesnt seem to come back to the button, and though I click again to make it continue, it gets hung (button not even reaches the pressed state)
I have tried the same thing without redirecting output (just printing in shell) but it doesnt work either
Here is a sample code (sorry for Spanish words). Just click on 'Test' (under 'File') and click 'parar' in new frame before it prints 'fin'. When you try to press the button again (while label is 'seguir') it gets hung
Your OnRun is blocking, and not returning to the MainLoop for a long time. This prevents any events from being delivered to any widget in the application, including paint events and mouse events as you've seen. You need to keep in mind when doing event driven programming like this that the events have to be dispatched at some point, and the handlers need to be quick about doing their job otherwise they will starve the rest of the application.
How can I do it then?Do I have to generate artificial events from within real menu/button events?Would it help to wrap functionality inside a method and call it from OnRun? Or is there a way of telling mainloop to recover event control while continuing executing code
Here is a sample code (sorry for Spanish words). Just click on ‘Test’
(under ‘File’) and click ‘parar’ in new frame before it prints ‘fin’.
When you try to press the button again (while label is ‘seguir’) it gets
hung
Your OnRun is blocking, and not returning to the MainLoop for a long
time. This prevents any events from being delivered to any widget in
the application, including paint events and mouse events as you’ve seen.
You need to keep in mind when doing event driven programming like
this that the events have to be dispatched at some point, and the
handlers need to be quick about doing their job otherwise they will
starve the rest of the application.
Maybe you can have a look at the wxpython demo: Process and Events>DelayedResult
Stani
···
On 3/9/07, fatima cabot <thisismydo@gmail.com> wrote:
How can I do it then?Do I have to generate artificial events from within
real menu/button events?Would it help to wrap functionality inside a method
and call it from OnRun? Or is there a way of telling mainloop to recover
event control while continuing executing code
On 3/9/07, Robin Dunn <robin@alldunn.com> wrote:
> fatima cabot wrote:
> > Here is a sample code (sorry for Spanish words). Just click on 'Test'
> > (under 'File') and click 'parar' in new frame before it prints 'fin'.
> > When you try to press the button again (while label is 'seguir') it gets
> > hung
>
> Your OnRun is blocking, and not returning to the MainLoop for a long
> time. This prevents any events from being delivered to any widget in
> the application, including paint events and mouse events as you've seen.
> You need to keep in mind when doing event driven programming like
> this that the events have to be dispatched at some point, and the
> handlers need to be quick about doing their job otherwise they will
> starve the rest of the application.
>
> Please read http://wiki.wxpython.org/index.cgi/LongRunningTasks for
> various strategies for allowing long running things to cooperate nicely
> with an event driven app.
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org
>