def motion_notify_event(self, mouse_event): if mouse_event.xdata and mouse_event.ydata: self.mouseMovedSignal.emit(mouse_event.xdata, mouse_event.ydata) else: self.mouseLeftSignal.emit() if self.selection_xrange and mouse_event.xdata: do_update = False (x_start, x_end) = self.mpl_canvas.axes.get_xlim() delta = abs((x_end - x_start) / 50.0) if abs(self.selection_xrange[0] - mouse_event.xdata) < delta: QtImport.QApplication.setOverrideCursor( QtImport.QCursor(QtImport.Qt.SizeHorCursor)) if self.mouse_clicked: self.selection_xrange[0] = mouse_event.xdata do_update = True elif abs(self.selection_xrange[1] - mouse_event.xdata) < delta: QtImport.QApplication.setOverrideCursor( QtImport.QCursor(QtImport.Qt.SizeHorCursor)) if self.mouse_clicked: self.selection_xrange[1] = mouse_event.xdata do_update = True if do_update: self.selection_span.set_xy([ [self.selection_xrange[0], 0], [self.selection_xrange[0], 1], [self.selection_xrange[1], 1], [self.selection_xrange[1], 0], [self.selection_xrange[0], 0], ]) self.mpl_canvas.fig.canvas.draw() self.mpl_canvas.fig.canvas.flush_events()
def _instance_mode_changed(self, mode): for widget, widget_name, master_sync in self._widget_events: if isinstance(widget, QtImport.QGroupBox): self.connect_group_box(widget, widget_name, master_sync) elif isinstance(widget, QtImport.QComboBox): self.connect_combobox(widget, widget_name, master_sync) elif isinstance(widget, QtImport.QLineEdit): self.connect_line_edit(widget, widget_name, master_sync) elif isinstance(widget, QtImport.QSpinBox): self.connect_spinbox(widget, widget_name, master_sync) elif isinstance(widget, QtImport.QDoubleSpinBox): self.connect_double_spinbox(widget, widget_name, master_sync) else: # verify if widget has the widgetSynchronize method!!! self.connect_generic_widget(widget, widget_name, master_sync) self._widget_events = [] if self.should_filter_event(): self.setCursor(QtImport.QCursor(QtImport.Qt.ForbiddenCursor)) else: self.setCursor(QtImport.QCursor(QtImport.Qt.ArrowCursor))