My program basically loops and wants to redraw a plot (using imshow() )
every 5 seconds or so. So it looks something like:
ion()
while 1:
do redraw business..
time.sleep(5)
The redrawing shows up fine, the only problem is that during the 5 seconds
of sleep, I cannot really move the figure window or really do anything with
it.
I am using MPL on windows with the 'Qt4Agg' backed, and running this code
from ipython (on the command line). I don't quite understand the threading
model of the GUI kit, vs. the main thread, so could someone enlighten me how
it works roughly, and what I need to do in a multi-threaded application in
order to update a figure periodically, and be able to move it around, and do
things with its figure window.
I am using MPL on windows with the 'Qt4Agg' backed, and running this code
from ipython (on the command line). I don't quite understand the threading
model of the GUI kit, vs. the main thread, so could someone enlighten me how
it works roughly, and what I need to do in a multi-threaded application in
order to update a figure periodically, and be able to move it around, and do
things with its figure window.
I don't know about QT, or if MPL has an abstraction layer for this, but with wx, there is a call:
wx.CallAfter(a_function, some_parameters)
that lets you make a call to the GUI from an external thread, so in your case, you would put your computation code is a separate thread, then call the updating code in a function from wx.CallAfter.
However, it sounds like you don't really need a separate thread, but rather just a non-blocking time delay.
In wx, you'd use a wxTimer for that (or wx.CallLater). I'm sure QT has something similar, and maybe MPL has an abstraction layer for the toolkits (if it doesn't this would be a nice contribution...)
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception