fsleyes_widgets.utils.runwindow

This module provides classes and functions for running a non-interactive process, and displaying its output.

This module provides the RunPanel and ProcessManager classes, and a couple of associated convenience functions.

RunPanel

A panel which displays a multiline text control, and a couple of buttons along the bottom.

ProcessManager

A thread which manages the execution of a child process, and capture of its output.

run

Runs the given command, displaying the output in a RunPanel.

class fsleyes_widgets.utils.runwindow.RunPanel(parent)[source]

Bases: Panel

A panel which displays a multiline text control, and a couple of buttons along the bottom. RunPanel instances are created by the run() function, and used/controlled by the ProcessManager.

One of the buttons is intended to closes the window in which this panel is contained. The second button is intended to terminate the running process. Both buttons are unbound by default, so must be manually configured by the creator.

The text panel and buttons are available as the following attributes:

  • text: The text panel.

  • closeButton: The Close window button.

  • killButton: The Terminate process button.

Create a RunPanel.

Parameters:

parent – The wx parent object.

class fsleyes_widgets.utils.runwindow.ProcessManager(cmd, parent, runPanel, onFinish)[source]

Bases: Thread

A thread which manages the execution of a child process, and capture of its output.

The process output is displayed in a RunPanel which must be passed to the ProcessManager on creation.

The termProc() method can be used to terminate the child process before it has completed.

Create a ProcessManager.

Parameters:
  • cmd – String or list of strings, the command to be executed.

  • parentwx parent object.

  • runPanel – A RunPanel instance , for displaying the child process output.

  • onFinish – Callback function to be called when the process finishes. May be None. Must accept two parameters, the GUI parent object, and the process return code.

run()[source]

Starts the process, then reads its output line by line, writing each line asynchronously to the RunPanel. When the process ends, the onFinish method (if there is one) is called. If the process finishes abnormally (with a non-0 exit code) a warning dialog is displayed.

termProc()[source]

Attempts to kill the running child process.

fsleyes_widgets.utils.runwindow.run(name, cmd, parent, onFinish=None, modal=True)[source]

Runs the given command, displaying the output in a RunPanel.

Parameters:
  • name – Name of the tool to be run, used in the window title.

  • cmd – String or list of strings, specifying the command to be executed.

  • parentwx parent object.

  • modal – If True, the frame which contains the RunPanel will be modal.

  • onFinish – Function to be called when the process ends. Must accept two parameters - a reference to the wx frame/dialog displaying the process output, and the exit code of the application.