def on_press(self, event): 'on button press we will see if the mouse is over us and store some data' #logging.info('press') if self.ignore_next_on_press: self.ignore_next_on_press = False #logging.info('ignored press') elif self.rect and event.inaxes == self.rect.axes: self.rect.set_xy((event.xdata, event.ydata)) self.rect.set_width(0) self.rect.set_height(0) self.press = event.xdata, event.ydata self.rect.figure.canvas.draw() else: width, height = self.ax.figure.canvas.get_width_height() #logging.info('ccc' + str(width) +' ' + str(height)) #logging.info('ccdc' + str(event.x) +' ' + str(event.y)) #logging.info('ccdc' + str(event.x/ width) +' ' + str(event.y / height)) is_x = event.y/height < 0.2 and event.x/width > 0.2 is_y = event.y/height > 0.2 and event.x/width < 0.2 if is_x or (not self.only_x and is_y): selected_marker = choose_marker(None, self.all_markers, False) if selected_marker: if is_x: self.changer.set_parameter(0, repr(selected_marker)) elif is_y: self.changer.set_parameter(1, repr(selected_marker)) services.replay_script(self)
def on_press(self, event): 'on button press we will see if the mouse is over us and store some data' #logging.info('press') if self.ignore_next_on_press: self.ignore_next_on_press = False #logging.info('ignored press') elif self.rect and event.inaxes == self.rect.axes: self.rect.set_xy((event.xdata, event.ydata)) self.rect.set_width(0) self.rect.set_height(0) self.press = event.xdata, event.ydata self.rect.figure.canvas.draw() else: width, height = self.ax.figure.canvas.get_width_height() #logging.info('ccc' + str(width) +' ' + str(height)) #logging.info('ccdc' + str(event.x) +' ' + str(event.y)) #logging.info('ccdc' + str(event.x/ width) +' ' + str(event.y / height)) is_x = event.y / height < 0.2 and event.x / width > 0.2 is_y = event.y / height > 0.2 and event.x / width < 0.2 if is_x or (not self.only_x and is_y): selected_marker = choose_marker(None, self.all_markers, False) if selected_marker: if is_x: self.changer.set_parameter(0, repr(selected_marker)) elif is_y: self.changer.set_parameter(1, repr(selected_marker)) services.replay_script(self)
def on_release(self, event): #logging.info('x:%s, y:%s' % (event.xdata, event.ydata)) #logging.info('x:%s, y:%s' % (np.round(event.xdata), np.round(event.ydata))) dim_x = self.dims[int(np.round(event.xdata))] dim_y = self.dims[int(np.round(event.ydata))] self.changer.set_parameter(1, repr(dim_x)) self.changer.set_parameter(2, repr(dim_y)) services.replay_script(self)
def on_pick(self, event): #logging.debug('allpick') if event.artist == self.color_label and not self.only_x: # luckily the on_pick is called before the on_press so we can # do this ugly hack (this is because on_pick doesn't work with labels) self.ignore_next_on_press = True selected_marker = choose_marker(None, self.all_markers, False) if selected_marker: self.changer.set_parameter(3, repr(selected_marker)) services.replay_script(self)
def button_click(button, changer): new_file = file_dialog(title, filename and os.path.dirname(filename)) if new_file: changer.set_parameter_by_name('filename', repr(new_file)) services.replay_script()
def on_release(self, event): 'on release we reset the press data' if self.press: self.press = None self.rect.figure.canvas.draw() services.replay_script(self)
def apply_clicked(button, data, changer): update_params(changer, data) services.replay_script()
def changed(combobox, changer): changer.set_parameter(0, repr(combobox.get_active_text())) services.replay_script()
def button_release(range, event, changer): changer.set_parameter(0, range.get_value()) services.replay_script()