7.2. pyopus.plotter.manager — Manager for Matplotlib plot windows¶
Manager for Matplotlib plot windows
The graphical part (PyQt + MatPlotLib) is running in a thread and the
part that issues the plotting commands (defined in the
interface module) runs in the main thread (or process).
The main thread uses a QPController object for sending and receiving
messages from the graphical thread. The messages are sent to the GUI by
emitting a messagePoster signal from a QPController.
A queue.Queue object is used for sending the response back to the
main thread. On the graphical thread’s side a QPControlWindow widget
is handling the received commands.
The processMessage slot in QPControlWindow calls the
QPControlWindow.interpretCommand() method that dispatches the received
message to the corresponding command handler.
-
class
pyopus.plotter.manager.QPController(args=[])¶ This is the controller responsible for sending commands to the GUI and collection responses.
args are passed to the
GUIentry()function which forwards them as command line arguments to theQApplicationobject.-
checkIfAlive()¶ Returns
Trueif the GUI thread is running.
-
figureAlive(tag)¶ Checks if the window of the given
Figureis still open.
-
figureDraw(tag)¶ Forces redrawing of the given
Figure.
-
join()¶ Waits for the GUI thread to finish.
KeyboardInterruptandSystemExitare caught and the GUI is stopped upon which the exception is re-raised.
-
lockGUI()¶ Marks the beginning of a section of code where Matplotlib API calls are made. Locking prevents these calls from interfering with the PyQt event loop and crashing the application.
-
postMessage(message)¶ This is the function that is invoked for every command that is sent to the GUI. It emits a
messagePostersignal.
-
startGUI()¶ Starts the GUI thread.
-
stopGUI()¶ Stops the GUI thread by sending it the
exitcommand.
-
unlockGUI()¶ Marks the end of a section of code where Matplotlib API calls are made. It reenables the PyQt event loop.
-