From f9d4be14b33c7bb9521e722aac8972ad934b64e1 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 21 Jul 2023 11:56:40 +0200 Subject: [PATCH] Add text getter and a test --- src/silx/gui/widgets/WaitingOverlay.py | 6 ++++++ src/silx/gui/widgets/test/test_waitingoverlay.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/silx/gui/widgets/WaitingOverlay.py b/src/silx/gui/widgets/WaitingOverlay.py index 447e4d6582..afba41e5e7 100644 --- a/src/silx/gui/widgets/WaitingOverlay.py +++ b/src/silx/gui/widgets/WaitingOverlay.py @@ -21,8 +21,14 @@ def __init__(self, parent: qt.QWidget) -> None: self._waitingButton.setStyleSheet("QPushButton { background-color: rgba(150, 150, 150, 40); border: 0px; border-radius: 10px; }") self._registerParent(parent) + def text(self) -> str: + """Returns displayed text""" + return self._waitingButton.text() + def setText(self, text: str): + """Set displayed text""" self._waitingButton.setText(text) + self._resize() def _listenedWidget(self, parent: qt.QWidget) -> qt.QWidget: """Returns widget to register event filter to according to parent""" diff --git a/src/silx/gui/widgets/test/test_waitingoverlay.py b/src/silx/gui/widgets/test/test_waitingoverlay.py index df96e869b2..785fd8e744 100644 --- a/src/silx/gui/widgets/test/test_waitingoverlay.py +++ b/src/silx/gui/widgets/test/test_waitingoverlay.py @@ -18,6 +18,11 @@ def test_show(qapp, qapp_utils, widget_parent): qapp_utils.qWaitForWindowExposed(widget) assert waitingOverlay._waitingButton.isWaiting() + waitingOverlay.setText("test") + qapp.processEvents() + assert waitingOverlay.text() == "test" + qapp_utils.qWait(1000) + waitingOverlay.hide() qapp.processEvents() assert not waitingOverlay._waitingButton.isWaiting()