Return value based on event in python -
i need value calculated calculate function being called once event being fired on_release function. value outside class.
class annotate(object): def __init__(self,diff): self.differnce = diff self.x0 = none self.y0 = none self.x1 = none self.y1 = none self.ax = plt.gca() self.ax.figure.canvas.mpl_connect('button_press_event', self.on_press) self.ax.figure.canvas.mpl_connect('button_release_event', self.on_release) def on_press(self, event): print 'press' self.x0 = event.xdata self.y0 = event.ydata # return x0,y0 def on_release(self, event): print 'release' x1 = event.xdata y1 = event.ydata self.calculate(int(self.x0), int(self.y0), int(x1), int(y1)) def calculate(self, a, b, c, d): print a, b, c, d print self.differnce sum = 0 count = 0 in range(a, c): j in range(b, d): sum = sum + self.differnce[i,j] count = count+1 print sum print count if (sum==0): if(count==0): print "try again" else: return sum/count = annotate(diff) print
Comments
Post a Comment