I'm trying to embed matplotlib on WX (which seems to work well for the moment). I'd like to avoid the wx mainloop() by making it run in a different thread than that of my main program.
The classical way of doing (using show() ) doesn't work. The first time, the figure becomes the main thread and my program stops running until I close the window. The second time I call it though, my program remains the main thread... Check the following code
from matplotlib.pylab import *
fig = Figure(figsize=(8,6))
data = range(10)
The screen prints 'here' only after closing the figure with the mouse. Then second figure appears, but the screen prints 'end' without me having to close the figure like the first one. The third figure though does not appear at all!
What am I doing wrong? I know I can use the show command only once, but my program runs sequently and I need to plot data while it runs. I also tried to run this function in a different thread but the results are similar :
t = threading.Thread(target = f)
tt = threading.Thread(target = f)
If the last three lines are neglected (plot only once), then it works perfectly! My main program terminates its execution and the figure stays alive until I close it. When f() is called two times though, both windows close when my program terminates...
Does anyone have an idea of how I should do this?
Thanks in advance,
PS: I also ttried the example embedding-in-wx-2.py which seems to be exactly my case for embedding my program in a GUI. The best would be running that example in a different thread or something like that in order to avoid the mainloop(). Any ideas?
Laboratoire de Télécommunications et Télédétection - TELE
Université catholique de Louvain UCL - FSA / ELEC
Bâtiment Stevin, a.156
Place du Levant, 2
B-1348 Louvain-La-Neuve, Belgium
Tel: +32 10/47.80.75