Chris, thank you very much for your reply. I encountered a related  
error, and was hoping you could help me understand this one too...
Using ipython -pylab I run the script below to generate a GUI, but  
when the GUI finishes running (after 3 button clicks), ipython crashes  
with the following error message: "Segmentation fault". This error  
does not occur if I remove the call to pyplot.close in  
myGUI.disconnect, nor does it occur if I use a key_press_event instead  
of a button_press_event.
Why is an error generated when I try to close the figure?
Why does this error occur for button_press_events but not  
key_press_events?

from numpy.random import rand
from matplotlib import pyplot

class myGUI:
     def __init__(self,x):
         self.fig = pyplot.gcf()
         self.n = 0
         self.connect()
         pyplot.plot(x)
         pyplot.show()

     def connect(self):
         self.cidbuttonpress =  
self.fig.canvas.mpl_connect('button_press_event', self.buttonpress)

     def disconnect(self):
         self.fig.canvas.mpl_disconnect(self.cidbuttonpress)
         pyplot.close(self.fig)

     def buttonpress(self,event):
         self.n += 1
         if self.n >=2:
             self.disconnect()

pyplot.figure()
obj = myGUI(rand(10))





On 22 May 2009, at 00:49, Christopher Barker wrote:

Todd Pataky wrote:
> I'm using the Enthought Python Distribution (EPD_Py25) and I enter
> IPython with the command: "ipython".

....

> This problem does not occur if I use EPD's PyLab (i.e. "ipython -
> pylab"). Does anyone know why?

because the whole point of the "pylab" flag to ipython is to tell
ipython to start up the MPL plotting stuff in separate thread so that it
can work like you want it to. If you don't' use that flag, then each
call to pyplot tries to start up a new app, ,but the old one is still
running, hence you problems.

ipython itself can be used for all sort of things that have nothing to
do with matplotlib, so that's not its default behavior.

Just use ipython -pylab if you want to do interactive plotting, that's
what it's for.

-Chris




------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to