def dropEvent(self, event): """ If the event data contains a workspace reference then request a plot of the workspace. :param event: A QDropEvent containing the MIME data of the action """ from matplotlib.backend_bases import LocationEvent workspace_names = event.mimeData().text().split('\n') # This creates a matplotlib LocationEvent so that the axis in which the # drop event occurred can be calculated try: x, y = self._canvas.mouseEventCoords(event.pos()) except AttributeError: # matplotlib v1.5 does not have mouseEventCoords try: dpi_ratio = self._canvas.devicePixelRatio() or 1 except AttributeError: dpi_ratio = 1 x = dpi_ratio * event.pos().x() y = dpi_ratio * self._canvas.figure.bbox.height / dpi_ratio - event.pos( ).y() location_event = LocationEvent('AxesGetterEvent', self._canvas, x, y) ax = location_event.inaxes if location_event.inaxes else self._canvas.figure.axes[ 0] self._plot_on_here(workspace_names, ax) QMainWindow.dropEvent(self, event)
def dropEvent(self, event): """ If the event data contains a workspace reference then request a plot of the workspace. :param event: A QDropEvent containing the MIME data of the action """ self._plot_on_here(event.mimeData().text().split('\n')) QMainWindow.dropEvent(self, event)
def dropEvent(self, event): """ If the event data contains a workspace reference then request a plot of the workspace. :param event: A QDropEvent containing the MIME data of the action """ from matplotlib.backend_bases import LocationEvent workspace_names = event.mimeData().text().split('\n') # This creates a matplotlib LocationEvent so that the axis in which the drop event occurred can be calculated x, y = self._canvas.mouseEventCoords(event.pos()) location_event = LocationEvent('AxesGetterEvent', self._canvas, x, y) ax = location_event.inaxes if location_event.inaxes else self._canvas.figure.axes[0] self._plot_on_here(workspace_names, ax) QMainWindow.dropEvent(self, event)