From 001f0aedcdbd183d0a8a0baaaaf599660a0f6ce3 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Thu, 16 Apr 2026 19:49:14 +0200 Subject: [PATCH] fix: remove eagerly import of safeproperty, safeslot and BECWidget from root --- bec_widgets/__init__.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bec_widgets/__init__.py b/bec_widgets/__init__.py index f88f7db6..9da5e9cb 100644 --- a/bec_widgets/__init__.py +++ b/bec_widgets/__init__.py @@ -2,8 +2,21 @@ import os import sys import bec_widgets.widgets.containers.qt_ads as QtAds -from bec_widgets.utils.bec_widget import BECWidget -from bec_widgets.utils.error_popups import SafeProperty, SafeSlot + +__all__ = ["BECWidget", "SafeSlot", "SafeProperty"] + + +def __getattr__(name): + if name == "BECWidget": + from bec_widgets.utils.bec_widget import BECWidget + + return BECWidget + if name in {"SafeSlot", "SafeProperty"}: + from bec_widgets.utils.error_popups import SafeProperty, SafeSlot + + return {"SafeSlot": SafeSlot, "SafeProperty": SafeProperty}[name] + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + if sys.platform.startswith("linux"): qt_platform = os.environ.get("QT_QPA_PLATFORM", "") @@ -15,5 +28,3 @@ QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.eConfigFlag.FocusHighlightin QtAds.CDockManager.setConfigFlag( QtAds.CDockManager.eConfigFlag.RetainTabSizeWhenCloseButtonHidden, True ) - -__all__ = ["BECWidget", "SafeSlot", "SafeProperty"]