def mouseReleaseEvent(self, event): x = event.x() # flipy so y=0 is bottom of canvas y = self.figure.bbox.height - event.y() button = self.buttond[event.button()] FigureCanvasAgg.button_release_event(self, x, y, button) self.draw()
def listen_for_remote(self): while self.parent_conn.poll(None): try: (msg, payload) = self.parent_conn.recv() except EOFError: return if msg != Msg.MOUSE_MOVE_EVENT: logger.debug("FigureCanvasAggRemote.listen_for_remote :: {}" .format(msg, payload)) try: if msg == Msg.DPI: dpi = payload matplotlib.rcParams['figure.dpi'] = dpi matplotlib.pyplot.clf() elif msg == Msg.RESIZE_EVENT: with self.plot_lock: (winch, hinch) = payload self.figure.set_size_inches(winch, hinch) FigureCanvasAgg.resize_event(self) self.draw() elif msg == Msg.MOUSE_PRESS_EVENT: (x, y, button) = payload if self.process_events.is_set(): with self.plot_lock: FigureCanvasAgg.button_press_event(self, x, y, button) elif msg == Msg.MOUSE_DOUBLE_CLICK_EVENT: (x, y, button) = payload if self.process_events.is_set(): with self.plot_lock: FigureCanvasAgg.button_press_event(self, x, y, button, dblclick = True) elif msg == Msg.MOUSE_RELEASE_EVENT: (x, y, button) = payload if self.process_events.is_set(): with self.plot_lock: FigureCanvasAgg.button_release_event(self, x, y, button) elif msg == Msg.MOUSE_MOVE_EVENT: (x, y) = payload if self.process_events.is_set(): with self.plot_lock: FigureCanvasAgg.motion_notify_event(self, x, y) elif msg == Msg.PRINT: (args, kwargs) = payload if self.process_events.is_set(): with self.plot_lock: old_size = self.figure.get_size_inches() width = kwargs.pop('width') height = kwargs.pop('height') self.figure.set_size_inches(width, height) FigureCanvasAgg.print_figure(self, *args, **kwargs) self.figure.set_size_inches(old_size[0], old_size[1]) else: raise RuntimeError("FigureCanvasAggRemote received bad message {}".format(msg)) except Exception: log_exception()
def mouseReleaseEvent(self, event): x = event.x() # flipy so y=0 is bottom of canvas y = self.figure.bbox.height - event.y() button = self.buttond.get(event.button()) if button is not None: FigureCanvasAgg.button_release_event(self, x, y, button, guiEvent=event) if DEBUG: print('button released')
def listen_for_remote(self): while self.parent_conn.poll(None): try: (msg, payload) = self.parent_conn.recv() except EOFError: return if msg != Msg.MOUSE_MOVE_EVENT: logging.debug( "FigureCanvasAggRemote.listen_for_remote :: {}".format( msg, payload)) try: if msg == Msg.RESIZE_EVENT: (winch, hinch) = payload self.figure.set_size_inches(winch, hinch) FigureCanvasAgg.resize_event(self) self.draw() elif msg == Msg.MOUSE_PRESS_EVENT: (x, y, button) = payload if self.process_events.is_set(): FigureCanvasAgg.button_press_event(self, x, y, button) elif msg == Msg.MOUSE_DOUBLE_CLICK_EVENT: (x, y, button) = payload if self.process_events.is_set(): FigureCanvasAgg.button_press_event(self, x, y, button, dblclick=True) elif msg == Msg.MOUSE_RELEASE_EVENT: (x, y, button) = payload if self.process_events.is_set(): FigureCanvasAgg.button_release_event( self, x, y, button) elif msg == Msg.MOUSE_MOVE_EVENT: (x, y) = payload if self.process_events.is_set(): FigureCanvasAgg.motion_notify_event(self, x, y) elif msg == Msg.PRINT: (args, kwargs) = payload if self.process_events.is_set(): FigureCanvasAgg.print_figure(self, *args, **kwargs) else: raise RuntimeError( "FigureCanvasAggRemote received bad message {}".format( msg)) except Exception: log_exception()