I would like to use matplotlib to incorporate plots into my fltk
application. I would like to do this by writing a python function to
create the appropriate graphic using matplotlib. When I want to update
the figure, I want to call an update function written by me in python
which computes the new graphic and displays it. The key point is that I
want to display the figure in a non-blocking way so that control can
return to my fltk application while the figure is still being displayed.
To prototype this I have created a file containing the following python
code
import sys
import fltk
import matplotlib
matplotlib.use('FltkAgg')
import pylab as p
import time
hf=p.figure()
ha=hf.add_subplot(1,1,1)
ha.plot([1,2,3])
p.draw()
time.sleep(5)
The problem I'm having is that if I execute these commands from a python
shell using:
execfile(filename)
(where filename is a file containing the above commands) then the figure
isn't being drawn until after sleep is executed. What I'd like is for
this function to just make the figure and leave it there while control
returns to the calling function. I can then create the plot from my
application(written in c) by linking with python and calling 'execfile'
where execfile contains the commands to make the plot.
I'm new to Python and appreciate any help.
Thanks.
Jeremy