Hi
sorry to post this again but all my attempts to solve the matplotlib
problem below failed and I desperately need this to progress.
I would like to use mpl_connect and disconnect to examine a series of 2d
arrays in turn (with a "for" loop), one after the other:
==> at each iteration I'd like to be able to use the left mouse button
to evaluate the sum of all x,y coordinates I select by (right) clicking
somewhere in the present array, and then switch to the next 2d data
array after I hit the right mouse button (button==3). I have no clue how
to do this and the program I wrote so far is just hanging there and does
nothing. Didn't see anything like this in the archive.
Any way to get out of this? Thanks for your help.
Eric
#=================
# stupid simple code just to illustrate the kind of things I would like to
achieve
# This does not work and just hang there...
#=================
import numpy as num
class offset:
def __init__(self) :
self.xc = 0.
self.yc = 0.
self.stay = 1
def on_click(self, event) :
if event.button == 1:
if event.inaxes is not None:
self.xc += event.xdata
self.yc += event.ydata
elif event.button == 3:
self.stay = 0
data1 = num.random.rand(10,10)
data2 = num.random.rand(10,10)
data3 = num.random.rand(10,10)
alldata = [data1, data2, data3]
for i in range(len(alldata)) :
imshow(alldata[i])
newoffset = offset()
binding = connect('button_press_event', newoffset.on_click)
while newoffset.stay :
pass
disconnect(binding)
print newoffset.xc, newoffset.yc
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users