0

when I try make a picture with pylab

import pylab
pylab.plot([0,1,2,3],[10,50,30,40])
pylab.savefig('graph.png')

in a wx application, no returned the terminal control.

1 Answer 1

0

I imagine that you are calling the wx main-loop in your main (only?) thread. However can you clarify the context of your code snippet? How do you make it into a "wx application" and why do you want terminal control? For example, do you want to see your figure on screen while also entering stuff at the terminal. Or do you want to just save it, without it showing on screen?

Anyway, the code snippet you give runs just fine for me, but if I do

import pylab
pylab.plot([0,1,2,3],[10,50,30,40])
pylab.savefig('graph.png')
pylab.plot()

Then if I run your code ...

  1. as "python snippet.py", then it just writes the file and exits, fine.

  2. from "ipython -wthreads", it shows the plot, saves it and returns control to me.

  3. from "ipython", then it does it's thing and never returns control.

This is because pylab.plot() calls the main loop of a GUI (gtk in my case, I expect wx will do the same).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.