From: darkside <in....@gm...> - 2007-06-28 17:39:27
|
Hello everyone, I'm trying to do a program that opens two different plots and select one point of each one with a mouse event. Here you have my example: -------------------------- import pylab def click(event): global x # allow to change global variable if event.button == 1: if event.inaxes: x = event.xdata # change global variable print " x - intern = ", x pylab.disconnect(cid) pylab.close() return x xlist = [] # list for x values global x #for i in xrange(4): fig = pylab.figure() ax = fig.add_subplot(111) pylab.title('primera') cid = pylab.connect('button_press_event', click) pylab.show() print " x - extern = ", x xlist.append(x) pylab.close() fig = pylab.figure() ax = fig.add_subplot(111) pylab.title('segunda') cid = pylab.connect('button_press_event', click) pylab.show() print " x - extern = ", x xlist.append(x) pylab.close() -------------------------------------------------- The problem is that the click event only works with the first plot, in the second one I get the plot, but not the mouse event. So my output is: x - intern = 0.696277915633 x - extern = 0.696277915633 x - extern = 0.696277915633 As you see, I only get the x-intern once. Does anybody know what I'm doing wrong? |