Hi, In your code, simply replace this: time.sleep(1) by that: p.waitforbuttonpress(1)
Using time.sleep will freeze the GUI because it will block the scripts execution hence preventing the Qt event loop from processing events and updating the GUI. HTH, Pierre Le 1 mars 2012 19:30, Andrew Collette <[email protected]> a écrit : > Hi, > > I'm transitioning from using IDL to using Python for analysis. > There's one (important) thing I can't get working, which is plotting > from a loop or script. The simplest fragment I could find that > reproduces the problem is: > > import numpy as np > import time > import pylab as p > > a = np.arange(10) > > for x in xrange(10): > p.plot(x) > time.sleep(1) > > Whether in a .py file or entered manually at the console, the result > is the same: a plot window appears but is blank and frozen (won't > respond to clicks); when the loop exits, all ten plots suddenly show > up in the figure at once. > > I've tried various combinations of pylab.ion(), draw(), show() with no > success. This is a real problem as it's very common in the IDL world > to plot many time series one after another, sometimes reading input > from the user for each one. For example, I need to manually go > through a dataset and throw out the bad traces, using input() in place > of the sleep command. > > Any ideas? I am using Spyder 2.0.13 as part of PythonXY. > > Thanks, > Andrew Collette > > -- > You received this message because you are subscribed to the Google Groups > "spyder" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/spyderlib?hl=en. > -- You received this message because you are subscribed to the Google Groups "spyder" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.
