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.
A panel which displays a multiline text control, and a couple of buttons along the bottom. |
|
A thread which manages the execution of a child process, and capture of its output. |
|
Runs the given command, displaying the output in a |
- 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 therun()
function, and used/controlled by theProcessManager
.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 theProcessManager
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.
parent –
wx
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 GUIparent
object, and the process return code.
- 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.
parent –
wx
parent object.modal – If
True
, the frame which contains theRunPanel
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.