cytoflowgui.matplotlib_backend_local

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 matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg, 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[source]

Bases: object

Messages sent between the local and remote canvases. There is an identical class in matplotlib_backend_remote because 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'
cytoflowgui.matplotlib_backend_local.log_exception()[source]

Catch and log exceptions (with their tracebacks

class cytoflowgui.matplotlib_backend_local.FigureCanvasQTAggLocal(figure, child_conn, working_pixmap)[source]

Bases: matplotlib.backends.backend_qtagg.FigureCanvasQTAgg

The local canvas; ie, the one in the GUI.

listen_for_remote()[source]

The main method for the thread that listens for messages from the remote canvas

send_to_remote()[source]

The main method for the thread that sends messages to the remote canvas

leaveEvent(event)[source]

Override the Qt event leaveEvent

mousePressEvent(event)[source]

Override the Qt event mousePressEvent

mouseDoubleClickEvent(event)[source]

Override the Qt event mouseDoubleClickEvent

mouseMoveEvent(event)[source]

Override the Qt event mouseMoveEvent

mouseReleaseEvent(event)[source]

Override the Qt event mouseReleaseEvent

resizeEvent(event)[source]

Override the Qt event resizeEvent

paintEvent(e)[source]

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)[source]

Pass a “print” request to the remote canvas (actually this is for rastering a figure and saving it to disk)