A matplotlib backend that renders across a process boundary. This module has the “local” canvas – the part that actually renders to a (Qt) window.
By default, matplotlib only works in one thread. For a GUI application, this is a problem because when matplotlib is working (ie, scaling a bunch of data points) the GUI freezes.
This module and
matplotlib_backend_remote implement a matplotlib backend
where the plotting done in one process (ie via pyplot, etc) shows up in a
canvas running in another process (the GUI). The canvas is the interface
across the process boundary: a “local” canvas, which is a GUI widget (in this
case a QWidget) and a “remote” canvas (running in the process where
pyplot.plot() etc. are used.) The remote canvas is a subclass of the Agg
renderer; when draw() is called, the remote canvas pulls the current buffer
out of the renderer and pushes it through a pipe to the local canvas, which
draws it on the screen. blit() is implemented too.
This takes care of one direction of data flow, and would be enough if we were
just plotting. However, we want to use matplotlib widgets as well, which
means there’s data flowing from the local canvas to the remote canvas too.
The local canvas is a subclass of
which is itself a sublcass of QWidget. The local canvas overrides several of
the event handlers, passing the event information to the remote canvas which
in turn runs the matplotlib event handlers.
- class cytoflowgui.matplotlib_backend_local.Msg¶
Messages sent between the local and remote canvases. There is an identical class in
matplotlib_backend_remotebecause we don’t want these two modules requiring one another
- DRAW = 'DRAW'¶
- BLIT = 'BLIT'¶
- WORKING = 'WORKING'¶
- RESIZE_EVENT = 'RESIZE'¶
- MOUSE_PRESS_EVENT = 'MOUSE_PRESS'¶
- MOUSE_MOVE_EVENT = 'MOUSE_MOVE'¶
- MOUSE_RELEASE_EVENT = 'MOUSE_RELEASE'¶
- MOUSE_DOUBLE_CLICK_EVENT = 'MOUSE_DOUBLE_CLICK'¶
- DPI = 'DPI'¶
- PRINT = 'PRINT'¶
Catch and log exceptions (with their tracebacks
- class cytoflowgui.matplotlib_backend_local.FigureCanvasQTAggLocal(figure, child_conn, working_pixmap)¶
The local canvas; ie, the one in the GUI.
The main method for the thread that listens for messages from the remote canvas
The main method for the thread that sends messages to the remote canvas
Override the Qt event leaveEvent
Override the Qt event mousePressEvent
Override the Qt event mouseDoubleClickEvent
Override the Qt event mouseMoveEvent
Override the Qt event mouseReleaseEvent
Override the Qt event resizeEvent
Copy the image from the buffer to the qt.drawable. In Qt, all drawing should be done inside of here when a widget is shown onscreen.
- print_figure(*args, **kwargs)¶
Pass a “print” request to the remote canvas (actually this is for rastering a figure and saving it to disk)