capsul.qt_gui module

Inheritance diagram of capsul.qt_gui, capsul.qt_gui.board_widget, capsul.qt_gui.widgets, capsul.qt_gui.widgets.activation_inspector, capsul.qt_gui.widgets.attributed_process_widget, capsul.qt_gui.widgets.links_debugger, capsul.qt_gui.widgets.pipeline_developer_view, capsul.qt_gui.widgets.pipeline_file_warning_widget, capsul.qt_gui.widgets.pipeline_user_view, capsul.qt_gui.widgets.viewer_widget

Graphical representations and tools for processes and pipelines. The module contains mainly widgets, based on Qt, using either PyQt4, PyQt5 or PySide.

capsul.qt_gui.board_widget submodule

Classes

BoardWidget

class capsul.qt_gui.board_widget.BoardWidget(controller, parent=None, name=None)[source]

Class that create a widget to visualize the controller status.

Method to initilaize the ControllerWidget class.

Parameters:
  • controller (derived Controller instance (mandatory)) – a class derived from the Controller class we want to parametrize with a widget.

  • parent (QtGui.QWidget (optional, default None)) – the controller widget parent widget.

  • name ((optional, default None)) – the name of this controller widget

browse_node(node, process_nodes, view_nodes, parent_pipeline)[source]

Find view_node and leaf nodes, ie. Process nodes

Parameters:
  • node (Node) – a capsul node

  • process_nodes (Node) – node of type processing_node

  • view_nodes (2-uplet) – contains the node of type view_node and the pipeline where this node is defined

create_board_tree()[source]

Method to create a tree with five columns (processings - status - execution time - memory - logs) that will summarize all the available quality control nodes

create_output_widget()[source]

Method to create the output controller widget built from the class controller output traits

create_viewer_tree()[source]

Method to create a tree with two columns (pipeline name - viewers) that will summarize all the available quality control nodes

capsul.qt_gui.widgets.activation_inspector submodule

A tool to debug and inspect nodes activation / deactivation in a pipeline.

Classes

ActivationInspectorApp

ActivationInspector

class capsul.qt_gui.widgets.activation_inspector.ActivationInspector(pipeline, ui_file=None, record_file=None, developper_view=None, parent=None)[source]

A Widget to display the pipeline activation process step by step.

Initialize the ActivationInspector class.

Parameters:
  • pipeline (capsul.Pipeline (mandatory)) – the pipeline we want to inspect.

  • ui_file (str (optional)) – the path to the qt user interface description file. If not specified, it will find its standard one.

  • record_file (str (optional)) – a file path where the activation steps are recorded. If not specified (None), it will create a temporary file.

  • developper_view (PipelineDeveloperView (optional)) – if specified it is possible to click on a plug to set a filter pattern and to update the pipeline activation accordingly.

add_controls_to_ui()[source]

Method to find dynamic controls

find_next()[source]

Forward search for a pattern in the activation list.

Returns:

is_found – 1 if a match has been found, 0 otherwise.

Return type:

int

find_previous()[source]

Backward search for a pattern in the activation list.

Returns:

is_found – True if a match has been found, False otherwise.

Return type:

bool

refresh_activation_from_record()[source]

Method to display pipeline activation steps from the recorded file.

set_filter_pattern(filter_pattern)[source]

Method that set a filter pattern.

Try a forward search followed by a backward one.

Parameters:

filter_pattern (str (mandatory)) – the filter pattern we want to set.

show()[source]

Shows the widget and its child widgets.

update_pipeline_activation(index)[source]

Method that is used to replay the activation step by step.

When a specific activation step is selected, the pipeline will reflect the selected activation status

class capsul.qt_gui.widgets.activation_inspector.ActivationInspectorApp(pipeline_path, record_file=None, *args, **kwargs)[source]

ActivationInspector Application. While developing a pipeline, nodes are connected through links. Nodes will be automatically activated or disabled depending on their connections (a mandatory link to a disabled node will disable the current one). You will often wonder why a node will not be activated. This tool helps to determine when and why by “playing” activation rules sequences step-by-step and displaying nodes which activate or deactivate at each step.

Method to initialize the ActivationInspectorApp class.

Parameters:
  • pipeline_path (str (mandatory)) – the name of the pipeline we want to load.

  • record_file (str (optional)) – a file where the pipeline activation steps are stored.

init_window()[source]

Method to initialize the main window.

capsul.qt_gui.widgets.attributed_process_widget submodule

Process or pipeline parameters view with attributes handling.

Classes

AttributedProcessWidget

class capsul.qt_gui.widgets.attributed_process_widget.AttributedProcessWidget(attributed_process, enable_attr_from_filename=False, enable_load_buttons=False, override_control_types=None, separate_outputs=True, user_data=None, userlevel=0, scroll=True)[source]

Process interface with attributes completion handling

Parameters:
  • attributed_process (Process instance) – process with attributes to be displayed

  • enable_attr_from_filename (bool (optional)) – if enabled, it will be possible to specify an input filename to build attributes from

  • override_control_types (dict (optional)) – if given, this is a “factory” dict assigning new controller editor types to some traits types in the parameters controller.

  • separate_outputs (bool) – if True, inputs and outputs (traits with output=True set) will be separated into two boxes.

  • user_data (any type (optional)) – optional user data that can be accessed by individual control editors

  • userlevel (int) – the current user level: some traits may be marked with a non-zero userlevel, and will only be visible if the ControllerWidget userlevel is more than (or equal) the trait level.

  • scroll (bool) – if True, the widget includes scrollbars in the parameters and attributes sections when needed, otherwise it will be a fixed size widget.

on_btn_load_json()[source]

Load attributes from a json file

on_btn_save_json()[source]

Save attributes in a json file

on_input_filename_changed(text)[source]

Input file path to guess completion attributes changed: update attributes

on_show_completion(visible)[source]

Toggle the visibility of paths parameters

on_use_fom_change(state)[source]

Use completion checkbox callback

set_use_fom()[source]

Setup the FOM doing its job

show_completion(visible=None)[source]

Show or hide completion (File, Directory, or Any parameters)

Parameters:

visible (bool (optional)) – show/hide. If None, switch the current visibility state.

capsul.qt_gui.widgets.pipeline_developer_view submodule

A Pipeline structure viewer widget, which displays pipeline nodes as boxes and links as lines, and provides pipeline editor features.

The only main class you should look at is the PipelineDeveloperView widget, the remaining is internal infrastructure:

pv = PipelineDeveloperView(pipeline, allow_open_controller=True,
                            enable_edition=True,show_sub_pipelines=True)
pv.show()

Classes

ColorType

Plug

EmbeddedSubPipelineItem

boxItem

NodeGWidget

HandleItem

PipelineScene

PipelineDeveloperView

class capsul.qt_gui.widgets.pipeline_developer_view.EmbeddedSubPipelineItem(sub_pipeline_wid)[source]

QGraphicsItem containing a sub-pipeline view

class capsul.qt_gui.widgets.pipeline_developer_view.HandleItem(parent=None)[source]

A handle that can be moved by the mouse

itemChange(self, change: QGraphicsItem.GraphicsItemChange, value: Any) Any[source]
mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent | None)[source]
focusInEvent(self, event: QFocusEvent | None)[source]
focusOutEvent(self, event: QFocusEvent | None)[source]
keyPressEvent(self, event: QKeyEvent | None)[source]
mousePressEvent(self, event: QGraphicsSceneMouseEvent | None)[source]
update(self, rect: QRectF = QRectF())[source]
update(self, ax: float, ay: float, width: float, height: float) None
class capsul.qt_gui.widgets.pipeline_developer_view.NodeGWidget(name, parameters, pipeline, parent=None, process=None, sub_pipeline=None, colored_parameters=True, logical_view=False, labels=[], show_opt_inputs=True, show_opt_outputs=True, userlevel=0)[source]
boundingRect(self) QRectF[source]
keyPressEvent(self, event: QKeyEvent | None)[source]
mouseDoubleClickEvent(self, event: QGraphicsSceneMouseEvent | None)[source]
mousePressEvent(self, event: QGraphicsSceneMouseEvent | None)[source]
paint(self, painter: QPainter | None, option: QStyleOptionGraphicsItem | None, widget: QWidget | None = None)[source]
update_labels(labels)[source]

Update colored labels

class capsul.qt_gui.widgets.pipeline_developer_view.PipelineDeveloperView(pipeline=None, parent=None, show_sub_pipelines=False, allow_open_controller=False, logical_view=False, enable_edition=False, userlevel=0)[source]

Pipeline representation as a graph, using boxes and arrows.

Based on Qt QGraphicsView, this can be used as a Qt QWidget.

Qt signals are emitted on a right click on a node box, and on a double click on a sub-pipeline box, to allow handling at a higher level. Default behaviors can be enabled using constructor parameters.

Ctrl + double click opens sub-pipelines in embedded views inside their parent box.

subpipeline_clicked
node_right_clicked
process_clicked
node_clicked
node_clicked_ctrl
plug_clicked
plug_right_clicked
colored_parameters
scene
__init__()[source]
set_pipeline()[source]
is_logical_view()[source]
set_logical_view()[source]
zoom_in()[source]
zoom_out()[source]
openProcessController()[source]
add_embedded_subpipeline()[source]
onLoadSubPipelineClicked()[source]
onOpenProcessController()[source]
enableNode()[source]
enable_step()[source]
disable_preceding_steps()[source]
disable_following_steps()[source]
enable_preceding_steps()[source]
enable_following_steps()[source]
set_switch_value()[source]
disable_done_steps()[source]
enable_all_steps()[source]
check_files()[source]
auto_dot_node_positions()[source]
save_dot_image_ui()[source]
reset_initial_nodes_positions()[source]
window()[source]
Parameters:
  • pipeline (Pipeline (optional)) – pipeline object to be displayed If omitted an empty pipeline will be used, and edition mode will be activated.

  • parent (QWidget (optional)) – parent widget

  • show_sub_pipelines (bool (optional)) – if set, sub-pipelines will appear as red/pink boxes and a double click on one of them will open another window with the sub-pipeline structure in it

  • allow_open_controller (bool (optional)) – if set, a right click on any box will open another window with the underlying node controller, allowing to see and edit parameters values, switches states, etc.

  • logical_view (bool (optional)) – if set, plugs and links between plugs are hidden, only links between nodes are displayed.

  • enable_edition (bool (optional)) – if set, pipeline edition features are available in GUI and menus: adding process boxes, drawing links etc. If pipeline is not specified, then edition will be activated anyway.

class IterativeProcessInput(engine)[source]
class ProcessModuleInput(display_str='process module/name', class_type_check=<function is_process>)[source]
class ProcessNameEdit(parent=None, class_type_check=<function is_process>)[source]

A specialized QLineEdit with completion for process name

add_embedded_subpipeline(subpipeline_name, scale=None)[source]

Adds an embedded sub-pipeline inside its parent node.

add_iterative_process()[source]

Insert an iterative process node in the pipeline. Asks for the process module/name, the node name, and iterative plugs before inserting.

add_node()[source]

Insert a custom node in the pipeline. Asks for the node module/name, and the node name before inserting.

add_optional_output_switch()[source]

Insert an optional output switch node in the pipeline. Asks for the switch inputs/outputs, and the node name before inserting.

add_process()[source]

Insert a process node in the pipeline. Asks for the process module/name, and the node name before inserting.

add_switch()[source]

Insert a switch node in the pipeline. Asks for the switch inputs/outputs, and the node name before inserting.

auto_dot_node_positions()[source]

Calculate pipeline nodes positions using graphviz/dot, and place the pipeline view nodes accordingly.

colored_parameters = True

If enabled (default), parameters in nodes boxes are displayed with color codes representing their state, and the state of their values: output parameters, empty values, existing files, non-existing files…

When colored_parameters is set, however, callbacks have to be installed to track changes in traits values, so this actually has an overhead. When colored_parameters is used, the color code is as follows:

  • black pamameter name: input

  • red parameter name: output

  • italics parameter name: Undefined, None, or empty string value

  • bold parameter name: existing file or directory name

  • regular font parameter name: non-existing file, or non-file parameter type

  • black plug: mandatory

  • green plug: optional

  • grey plug: mandatory, inactive

  • light green plug: optional, inactive

  • grey link: inactive

  • orange link: active

  • dotted line link: weak link

dragEnterEvent(event)[source]

Event handler when the mouse enters the widget.

Parameters:

event – event

dragMoveEvent(event)[source]

Event handler when the mouse moves in the widget.

Parameters:

event – event

dropEvent(event)[source]

Event handler when something is dropped in the widget.

Parameters:

event – event

drop_process(path)[source]

Find the dropped process in the system’s paths.

Parameters:

path – class’s path (e.g. “nipype.interfaces.spm.Smooth”) (str)

edit_sub_pipeline

Signal emitted when a sub-pipeline has to be edited

edition_enabled()[source]

Get the editable state

ensure_pipeline(pipeline)[source]

Check that we have a pipeline or a process

export_to_db_scans

Signal emitted when an Input Filter has to be linked to database_scans

is_logical_view()[source]

in logical view mode, plugs and links between plugs are hidden, only links between nodes are displayed.

is_restricted_edition_mode()[source]

Get the restricted mode status

Returns:

enabled

Return type:

bool

link_right_clicked

Signal emitted when a link is right-clicked

load_pipeline_parameters(root_path='')[source]

Loading and setting pipeline parameters (inputs and outputs) from a Json file. :return:

mouseMoveEvent(self, event: QMouseEvent | None)[source]
mousePressEvent(self, event: QMouseEvent | None)[source]
mouseReleaseEvent(self, event: QMouseEvent | None)[source]
node_clicked

Signal emitted when a node box has to be open.

node_clicked_ctrl

Signal emitted when a node box has to be in the foreground.

node_right_clicked

Signal emitted when a node box is right-clicked

onLoadSubPipelineClicked(node_name, sub_pipeline, modifiers)[source]

Event to load a open a sub-pipeline view. If ctrl is pressed the new view will be embedded in its parent node box.

onOpenProcessController(node_name, process)[source]

Event to open a sub-process/sub-pipeline controller

open_background_menu()[source]

Open the right-click menu when triggered from the pipeline background.

open_filter

Signal emitted when an Input Filter has to be opened

open_node_menu(node_name, process)[source]

right-click popup menu for nodes

plug_clicked

Signal emitted when a plug is clicked

plug_right_clicked

Signal emitted when a plug is right-clicked

release_pipeline(delete=False)[source]

Releases the pipeline currently viewed (and remove the callbacks)

If delete is set, this means the view is within deletion process and a new scene should not be built

reset_initial_nodes_positions()[source]

Set each pipeline node to its “saved” position, ie the one which may be found in the “node_position” variable of the pipeline.

save_dot_image_ui()[source]

Ask for a filename using the file dialog, and save a graphviz/dot representation of the pipeline. The pipeline representation follows the current visualization mode (“regular” or “logical” with smaller boxes) with one link of a given type (active, weak) between two given boxes: all parameters are not represented.

save_pipeline()[source]

Ask for a filename using the file dialog, and save the pipeline as a XML, JSON or python file.

save_pipeline_parameters()[source]

Saving pipeline parameters (inputs and outputs) to a Json file. :return:

scene = None

PipelineScene

the main scene.

Type:

type

set_enable_edition(state=True)[source]

Set the editable state. Edition allows to modify a pipeline: adding / removing process boxes and switches, drawing links, etc.

set_logical_view(state)[source]

in logical view mode, plugs and links between plugs are hidden, only links between nodes are displayed.

Parameters:

state (bool (mandatory)) – to set/unset the logical view mode

set_pipeline(pipeline)[source]

Assigns a new pipeline to the view.

set_restricted_edition_mode(enabled)[source]

Set the restricted edition mode. In restricted mode, some background menu actions (“add process”, “open node controller”…) are not available.

Parameters:

enabled (bool) –

show_optional_inputs()[source]

Added to choose to visualize optional inputs.

show_optional_outputs()[source]

Added to choose to visualize optional outputs.

subpipeline_clicked

Signal emitted when a sub pipeline has to be open.

switch_clicked

Signal emitted when a switch box has to be open.

wheelEvent(self, event: QWheelEvent | None)[source]
window()[source]

window() is overloaded from QWidget.window() to handle embedded views cases. A PipelineDeveloperView may be displayed inside a NodeGWidget. In this case, we want to go up to the parent scene’s window to the “real” top window, where QWidget.window() will end in the current graphics scene.

zoom_in()[source]

Zoom the view in, applying a 1.2 zoom factor

zoom_out()[source]

Zoom the view out, applying a 1/1.2 zool factor

class capsul.qt_gui.widgets.pipeline_developer_view.PipelineScene(parent=None, userlevel=0)[source]
helpEvent(event)[source]

Display tooltips on plugs and links

keyPressEvent(self, event: QKeyEvent | None)[source]

Tooltip text for the fiven link

Parameters:

source_dest (tuple (2 tuples of 2 strings)) – link description: ((source_node, source_param), (dest_node, dest_param))

plug_tooltip_text(node, name)[source]

Tooltip text for a node plug

class capsul.qt_gui.widgets.pipeline_developer_view.Plug(color, name, height, width, activated=True, optional=False, parent=None)[source]
mousePressEvent(self, event: QGraphicsSceneMouseEvent | None)[source]
class capsul.qt_gui.widgets.pipeline_developer_view.boxItem(parent=None)[source]
focusInEvent(self, event: QFocusEvent | None)[source]
focusOutEvent(self, event: QFocusEvent | None)[source]
keyPressEvent(self, event: QKeyEvent | None)[source]

capsul.qt_gui.widgets.pipeline_file_warning_widget submodule

GUI for pipeline file inputs/outputs checking

Classes

PipelineFileWarningWidget

class capsul.qt_gui.widgets.pipeline_file_warning_widget.PipelineFileWarningWidget(missing_inputs, overwritten_outputs, parent=None)[source]

This class is a GUI for pipeline file inputs/outputs checking.

It allows to check if there are missing inputs which may prevent the pipeline from running, or if there are already existing outputs which would be overwritten if the pipeline runs.

It will show warnings accordingly.

The widget is built from the output of capsul.pipeline_tools.nodes_with_missing_inputs() and capsul.pipeline_tools.nodes_with_existing_outputs()

capsul.qt_gui.widgets.pipeline_user_view submodule

A widget to visualize a pipeline as a simple workflow

Classes

PipelineUserView

class capsul.qt_gui.widgets.pipeline_user_view.PipelineUserView(pipeline)[source]

A widget to visualize a pipeline as a simple workflow.

Uses Graphviz dot tool.

Initialize the WorkflowViewer class

update(self)[source]
update(self, a0: QRect) None
update(self, a0: QRegion) None
update(self, ax: int, ay: int, aw: int, ah: int) None

capsul.qt_gui.widgets.viewer_widget submodule

Result viewer

Classes

ViewerWidget

class capsul.qt_gui.widgets.viewer_widget.ViewerWidget(viewer_node_name, pipeline, study_config)[source]

View result class

Method to initialize a ViewerWidget class.

Parameters:
  • viewer_node_name (str) – the name of the node containing the viewer process

  • pipeline (str) – the full pipeline in order to get the viewer input trait values since the viewer node is unactivated

onCreateViewerClicked()[source]

Event to create the viewer