From bc8a3282db712f7301703c6ea5940453ca852c54 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Wed, 6 Aug 2025 20:24:40 +0200 Subject: [PATCH] feat(widget_io): widget hierarchy can grap all bec connectors from the widget recursively --- bec_widgets/utils/widget_io.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bec_widgets/utils/widget_io.py b/bec_widgets/utils/widget_io.py index 22a754d9..1f4243cb 100644 --- a/bec_widgets/utils/widget_io.py +++ b/bec_widgets/utils/widget_io.py @@ -553,6 +553,20 @@ class WidgetHierarchy: WidgetIO.set_value(child, value) WidgetHierarchy.import_config_from_dict(child, widget_config, set_values) + @staticmethod + def get_bec_connectors_from_parent(widget) -> list: + """ + Return all BECConnector instances that are descendants of the given widget, + including the widget itself if it is a BECConnector. + """ + from bec_widgets.utils import BECConnector + + connectors = [] + if isinstance(widget, BECConnector): + connectors.append(widget) + connectors.extend(widget.findChildren(BECConnector)) + return connectors + # Example usage def hierarchy_example(): # pragma: no cover