WidgetManager (widgetmanager
)
- class orangecanvas.scheme.widgetmanager.WidgetManager(*args, **kwargs)[source]
Bases:
QObject
WidgetManager class is responsible for creation, tracking and deletion of UI elements constituting an interactive workflow.
It does so by reacting to changes in the underlying workflow model, creating and destroying the components when needed.
This is an abstract class, subclassed MUST reimplement at least
create_widget_for_node()
anddelete_widget_for_node()
.The widgets created with
create_widget_for_node()
will automatically receive dispatched events:WorkflowEvent.InputLinkAdded
- when a new input link is added to the workflow.WorkflowEvent.InputLinkRemoved
- when a input link is removed.WorkflowEvent.OutputLinkAdded
- when a new output link is added to the workflow.WorkflowEvent.OutputLinkRemoved
- when a output link is removed.WorkflowEvent.InputLinkStateChange
- when the input link’s runtime state changes.WorkflowEvent.OutputLinkStateChange
- when the output link’s runtime state changes.WorkflowEvent.NodeStateChange
- when the node’s runtime state changes.WorkflowEvent.WorkflowEnvironmentChange
- when the workflow environment changes.
See also
Scheme.add_link()
,Scheme.remove_link()
,Scheme.runtime_env()
,NodeEvent
,LinkEvent
- widget_for_node_added(SchemeNode, QWidget)
A new QWidget was created and added by the manager.
Signal emitted when a QWidget was created and added by the manager.
- widget_for_node_removed(SchemeNode, QWidget)
A QWidget was removed, hidden and will be deleted when appropriate.
Signal emitted when a QWidget was removed and will be deleted.
- class CreationPolicy(value)[source]
Bases:
Enum
Widget Creation Policy.
- Normal = 'Normal'
Widgets are scheduled to be created from the event loop, or when first accessed with widget_for_node
- Immediate = 'Immediate'
Widgets are created immediately when a node is added to the workflow model.
- OnDemand = 'OnDemand'
Widgets are created only when first accessed with widget_for_node (e.g. when activated in the view).
- set_creation_policy(policy: CreationPolicy) None [source]
Set the widget creation policy.
- create_widget_for_node(node: SchemeNode) QWidget [source]
Create and initialize a widget for node.
This is an abstract method. Subclasses must reimplemented it.
- delete_widget_for_node(node: SchemeNode, widget: QWidget) None [source]
Remove and delete widget for node.
This is an abstract method. Subclasses must reimplemented it.
- node_for_widget(widget: QWidget) SchemeNode | None [source]
Return the node for widget.
- widget_for_node(node: SchemeNode) QWidget | None [source]
Return the widget for node.
- ensure_created(node: SchemeNode) None [source]
Ensure that the widget for node is created.
- activate_widget_for_node(node: SchemeNode, widget: QWidget) None [source]
Activate the widget for node (show and raise above other)
- raise_widgets_to_front()[source]
Raise all current visible widgets to the front.
The widgets will be stacked by activation order.
- restore_window_state(state: List[Tuple[SchemeNode, bytes]]) None [source]
Restore the window state.
- save_widget_geometry(node: SchemeNode, widget: QWidget) bytes [source]
Save and return the current geometry and state for node.
- restore_widget_geometry(node: SchemeNode, widget: QWidget, state: bytes) bool [source]
Restore the widget geometry and state for node.
Return True if the geometry was restored successfully.
The default implementation does nothing.
Return a list of extra actions that can be inserted into context menu in the workflow editor.
Subclasses can reimplement this method to extend the default context menu.
- Parameters:
node (SchemeNode) – The node for which the context menu is requested.
- Returns:
actions – Actions that are appended to the default menu.
- Return type:
List[QAction]