Chaco plot - how to force real-time update

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Chaco plot - how to force real-time update

Denis Lepchev
Hello guys,
We use chaco+traits as front-end for  C module which makes  some heavy calculations. One of the pieces of code is a loop in python, that calls for C function, gets some data from it and plots it on the screen.
The problem is that plot is being updated only when loop ends - it draws all the data at once, instead of updating the plot in loop. I tried to call request_redraw() or invalidate_and_redraw() inside the loop, but nothing helps.
Seems that request_redraw is not being processed while there is heavy system load in the background? How can I force an update, and to wait for actual redraw before proceeding to the next step in the loop?
Any ideas?

Thanks in advance,
Denis

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Chaco plot - how to force real-time update

Peter Wang
On Sun, Dec 5, 2010 at 4:26 PM, Denis Lepchev <[hidden email]> wrote:

> Hello guys,
> We use chaco+traits as front-end for  C module which makes  some heavy
> calculations. One of the pieces of code is a loop in python, that calls for
> C function, gets some data from it and plots it on the screen.
> The problem is that plot is being updated only when loop ends - it draws all
> the data at once, instead of updating the plot in loop. I tried to call
> request_redraw() or invalidate_and_redraw() inside the loop, but nothing
> helps.
> Seems that request_redraw is not being processed while there is heavy system
> load in the background? How can I force an update, and to wait for actual
> redraw before proceeding to the next step in the loop?
> Any ideas?

What is the interaction between the loop that calls the C function and
the GUI mainloop of whatever toolkit you are using (wx, Qt, etc.)?
Are you doing this on the main UI thread, or in a separate thread?  I
suspect that your issue is that you are calling the C function on the
UI thread, so that while the C function is running, the application
becomes unresponsive even to the windowing system's system-level paint
events.  Thus, no amount of calling "request_redraw()" is going to
really help, because that still requires the underlying GUI toolkit to
respond to a system repaint event.

If this is indeed the case, then I would suggest moving the
calculation loop into its own thread.  If that is not possible, then
you should try calling e.g. QApplization.processEvent (see
http://doc.trolltech.com/stable/qcoreapplication.html#processEvents)
if you are using Qt, or try calling wx's Window.Update() method.  (The
wx.Window object can be referenced via
outermost_chaco_component.window.control.)


HTH,
Peter
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev