Scheme (scheme)
Scheme Workflow
The Scheme class defines a DAG (Directed Acyclic Graph) workflow.
- class orangecanvas.scheme.scheme.Scheme(parent: Optional[PyQt5.QtCore.QObject] = None, title: str = '', description: str = '', env: Mapping[str, Any] = {}, **kwargs: Any)[source]
Bases:
PyQt5.QtCore.QObjectAn
QObjectsubclass representing the scheme widget workflow with annotations.- Parameters
- title_changed(title)
Signal emitted when the title of scheme changes.
- description_changed(description)
Signal emitted when the description of scheme changes.
- node_added(node)
Signal emitted when a node is added to the scheme.
- node_removed(node)
Signal emitted when a node is removed from the scheme.
- link_added(link)
Signal emitted when a link is added to the scheme.
- link_removed(link)
Signal emitted when a link is removed from the scheme.
- annotation_added(annotation)
Signal emitted when a annotation is added to the scheme.
- annotation_removed(annotation)
Signal emitted when a annotation is removed from the scheme.
- property nodes
A list of all nodes (
SchemeNode) currently in the scheme.
- property links
A list of all links (
SchemeLink) currently in the scheme.
- property annotations
A list of all annotations (
BaseSchemeAnnotation) in the scheme.
- add_node(node: orangecanvas.scheme.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: orangecanvas.scheme.node.SchemeNode)[source]
Insert node into self.nodes at the specified position index
- new_node(description: orangecanvas.registry.description.WidgetDescription, title: Optional[str] = None, position: Optional[Tuple[float, float]] = None, properties: Optional[dict] = None) orangecanvas.scheme.node.SchemeNode[source]
Create a new
SchemeNodeand add it to the scheme.Same as:
scheme.add_node(SchemeNode(description, title, position, properties))
- Parameters
See also
- remove_node(node: orangecanvas.scheme.node.SchemeNode) orangecanvas.scheme.node.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(index: int, link: orangecanvas.scheme.link.SchemeLink)[source]
Insert link into self.links at the specified position index.
- add_link(link: orangecanvas.scheme.link.SchemeLink) None[source]
Add a link to the scheme.
- Parameters
link (
SchemeLink) – An initialized link instance to add to the scheme.
- new_link(source_node: orangecanvas.scheme.node.SchemeNode, source_channel: orangecanvas.registry.description.OutputSignal, sink_node: orangecanvas.scheme.node.SchemeNode, sink_channel: orangecanvas.registry.description.InputSignal) orangecanvas.scheme.link.SchemeLink[source]
Create a new
SchemeLinkfrom 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 fromsource_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 fromsink_node.input_channels()
See also
- remove_link(link: orangecanvas.scheme.link.SchemeLink) None[source]
Remove a link from the scheme.
- Parameters
link (
SchemeLink) – Link instance to remove.
- check_connect(link: orangecanvas.scheme.link.SchemeLink) None[source]
Check if the link can be added to the scheme and raise an appropriate exception.
- Can raise:
SchemeCycleErrorif the link would introduce a loop in the graph which does not allow loops.IncompatibleChannelTypeErrorif the channel types are not compatibleSinkChannelErrorif a sink channel has a Single flag specification and the channel is already connected.DuplicatedLinkErrorif a link duplicates an already present link.
- creates_cycle(link: orangecanvas.scheme.link.SchemeLink) bool[source]
Return True if link would introduce a cycle in the scheme.
- Parameters
link (
SchemeLink) –
- compatible_channels(link: orangecanvas.scheme.link.SchemeLink) bool[source]
Return True if the channels in link have compatible types.
- Parameters
link (
SchemeLink) –
- can_connect(link: orangecanvas.scheme.link.SchemeLink) bool[source]
Return True if link can be added to the scheme.
See also
- upstream_nodes(start_node: orangecanvas.scheme.node.SchemeNode) Set[orangecanvas.scheme.node.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: orangecanvas.scheme.node.SchemeNode) Set[orangecanvas.scheme.node.SchemeNode][source]
Return a set of all nodes downstream from start_node.
- Parameters
start_node (
SchemeNode) –
- is_ancestor(node: orangecanvas.scheme.node.SchemeNode, child: orangecanvas.scheme.node.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
node (
SchemeNode) –child (
SchemeNode) –
- children(node: orangecanvas.scheme.node.SchemeNode) Set[orangecanvas.scheme.node.SchemeNode][source]
Return a set of all children of node.
- parents(node: orangecanvas.scheme.node.SchemeNode) Set[orangecanvas.scheme.node.SchemeNode][source]
Return a set of all parents of node.
- input_links(node: orangecanvas.scheme.node.SchemeNode) List[orangecanvas.scheme.link.SchemeLink][source]
Return a list of all input links (
SchemeLink) connected to the node instance.
- output_links(node: orangecanvas.scheme.node.SchemeNode) List[orangecanvas.scheme.link.SchemeLink][source]
Return a list of all output links (
SchemeLink) connected to the node instance.
- propose_links(source_node: orangecanvas.scheme.node.SchemeNode, sink_node: orangecanvas.scheme.node.SchemeNode, source_signal: Optional[orangecanvas.registry.description.OutputSignal] = None, sink_signal: Optional[orangecanvas.registry.description.InputSignal] = None) List[Tuple[orangecanvas.registry.description.OutputSignal, orangecanvas.registry.description.InputSignal, int]][source]
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: orangecanvas.scheme.annotations.BaseSchemeAnnotation) None[source]
Insert annotation into self.annotations at the specified position index.
- add_annotation(annotation: orangecanvas.scheme.annotations.BaseSchemeAnnotation) None[source]
Add an annotation (
BaseSchemeAnnotationsubclass) instance to the scheme.
- remove_annotation(annotation: orangecanvas.scheme.annotations.BaseSchemeAnnotation) None[source]
Remove the annotation instance 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
- get_runtime_env(key: str, default: Optional[Any] = 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:
types.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:
orangecanvas.scheme.errors.SchemeTopologyErrorA link would create a cycle in the scheme.
- class orangecanvas.scheme.scheme.IncompatibleChannelTypeError[source]
Bases:
TypeErrorSource and sink channels do not have compatible types