Scheme (scheme)

Scheme Workflow

The Scheme class defines a DAG (Directed Acyclic Graph) workflow.

class orangecanvas.scheme.scheme.Scheme(parent: QObject | None = None, title: str = '', description: str = '', env: Mapping[str, Any] = {}, **kwargs: Any)[source]

Bases: QObject

An QObject subclass representing the scheme widget workflow with annotations.

Parameters:
  • parent (QObject) – A parent QObject item (default None).

  • title (str) – The scheme title.

  • description (str) – A longer description of the scheme.

  • env (Mapping[str, Any]) – Extra workflow environment definition (application defined).

title_changed(title)

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when the title of scheme changes.

description_changed(description)

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when the description of scheme changes.

node_added(node)

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when a node is added to the scheme.

node_removed(node)

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when a node is removed from the scheme.

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when a link is added to the scheme.

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when a link is removed from the scheme.

annotation_added(annotation)

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when a annotation is added to the scheme.

annotation_removed(annotation)

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

Signal emitted when a annotation is removed from the scheme.

runtime_env_changed(key: str, newvalue: str | None, oldvalue: str | None)

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

property nodes: List[SchemeNode]

A list of all nodes (SchemeNode) currently in the scheme.

A list of all links (SchemeLink) currently in the scheme.

property annotations: List[BaseSchemeAnnotation]

A list of all annotations (BaseSchemeAnnotation) in the scheme.

set_title(title: str) None[source]

Set the scheme title text.

set_description(description: str) None[source]

Set the scheme description text.

add_node(node: SchemeNode) None[source]

Add a node to the scheme. An error is raised if the node is already in the scheme.

Parameters:

node (SchemeNode) – Node instance to add to the scheme.

insert_node(index: int, node: SchemeNode)[source]

Insert node into self.nodes at the specified position index

new_node(description: WidgetDescription, title: str | None = None, position: Tuple[float, float] | None = None, properties: dict | None = None) SchemeNode[source]

Create a new SchemeNode and add it to the scheme.

Same as:

scheme.add_node(SchemeNode(description, title, position,
                           properties))
Parameters:
  • description (WidgetDescription) – The new node’s description.

  • title (str, optional) – Optional new nodes title. By default description.name is used.

  • position (Tuple[float, float]) – Optional position in a 2D space.

  • properties (dict, optional) – A dictionary of optional extra properties.

remove_node(node: SchemeNode) SchemeNode[source]

Remove a node from the scheme. All links into and out of the node are also removed. If the node in not in the scheme an error is raised.

Parameters:

node (SchemeNode) – Node instance to remove.

Insert link into self.links at the specified position index.

Add a link to the scheme.

Parameters:

link (SchemeLink) – An initialized link instance to add to the scheme.

Create a new SchemeLink from arguments and add it to the scheme. The new link is returned.

Parameters:
  • source_node (SchemeNode) – Source node of the new link.

  • source_channel (OutputSignal) – Source channel of the new node. The instance must be from source_node.output_channels()

  • sink_node (SchemeNode) – Sink node of the new link.

  • sink_channel (InputSignal) – Sink channel of the new node. The instance must be from sink_node.input_channels()

Remove a link from the scheme.

Parameters:

link (SchemeLink) – Link instance to remove.

check_connect(link: SchemeLink) None[source]

Check if the link can be added to the scheme and raise an appropriate exception.

Can raise:
creates_cycle(link: SchemeLink) bool[source]

Return True if link would introduce a cycle in the scheme.

Parameters:

link (SchemeLink)

compatible_channels(link: SchemeLink) bool[source]

Return True if the channels in link have compatible types.

Parameters:

link (SchemeLink)

can_connect(link: SchemeLink) bool[source]

Return True if link can be added to the scheme.

upstream_nodes(start_node: SchemeNode) Set[SchemeNode][source]

Return a set of all nodes upstream from start_node (i.e. all ancestor nodes).

Parameters:

start_node (SchemeNode)

downstream_nodes(start_node: SchemeNode) Set[SchemeNode][source]

Return a set of all nodes downstream from start_node.

Parameters:

start_node (SchemeNode)

is_ancestor(node: SchemeNode, child: SchemeNode) bool[source]

Return True if node is an ancestor node of child (is upstream of the child in the workflow). Both nodes must be in the scheme.

Parameters:
children(node: SchemeNode) Set[SchemeNode][source]

Return a set of all children of node.

parents(node: SchemeNode) Set[SchemeNode][source]

Return a set of all parents of node.

Return a list of all input links (SchemeLink) connected to the node instance.

Return a list of all output links (SchemeLink) connected to the node instance.

Return a list of ordered (OutputSignal, InputSignal, weight) tuples that could be added to the scheme between source_node and sink_node.

Note

This can depend on the links already in the scheme.

insert_annotation(index: int, annotation: BaseSchemeAnnotation) None[source]

Insert annotation into self.annotations at the specified position index.

add_annotation(annotation: BaseSchemeAnnotation) None[source]

Add an annotation (BaseSchemeAnnotation subclass) instance to the scheme.

remove_annotation(annotation: BaseSchemeAnnotation) None[source]

Remove the annotation instance from the scheme.

clear() None[source]

Remove all nodes, links, and annotation items from the scheme.

sync_node_properties() None[source]

Called before saving, allowing a subclass to update/sync.

The default implementation does nothing.

save_to(stream, pretty=True, **kwargs)[source]

Save the scheme as an xml formatted file to stream

See also

readwrite.scheme_to_ows_stream

load_from(stream, *args, **kwargs)[source]

Load the scheme from xml formatted stream.

Any extra arguments are passed to readwrite.scheme_load

See also

readwrite.scheme_load

set_runtime_env(key: str, value: Any) None[source]

Set a runtime environment variable key to value

get_runtime_env(key: str, default: Any | None = None) Any[source]

Return a runtime environment variable for key.

runtime_env() Mapping[str, Any][source]

Return (a view to) the full runtime environment.

The return value is a types.MappingProxyType of the underlying environment dictionary. Changes to the env. will be reflected in it.

class WindowGroup(name='', default=False, state=[])[source]

Bases: SimpleNamespace

window_group_presets() List[WindowGroup][source]

Return a collection of preset window groups and their encoded states.

The base implementation returns an empty list.

class orangecanvas.scheme.scheme.SchemeCycleError[source]

Bases: SchemeTopologyError

A link would create a cycle in the scheme.

class orangecanvas.scheme.scheme.IncompatibleChannelTypeError[source]

Bases: TypeError

Source and sink channels do not have compatible types

class orangecanvas.scheme.scheme.SinkChannelError[source]

Bases: SchemeTopologyError

Sink channel already connected.

class orangecanvas.scheme.scheme.DuplicatedLinkError[source]

Bases: SchemeTopologyError

A link duplicates another link already present in the scheme.