From c800214535c518f102c44e3655311081035eb8b3 Mon Sep 17 00:00:00 2001 From: michaellans Date: Thu, 2 Jul 2026 12:47:06 -0700 Subject: [PATCH 1/2] busy cursor wrapper in utils --- src/badger/gui/utils.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/badger/gui/utils.py b/src/badger/gui/utils.py index ef5f03a9..c3d977ef 100644 --- a/src/badger/gui/utils.py +++ b/src/badger/gui/utils.py @@ -5,10 +5,12 @@ from importlib import resources from typing import Any from PyQt5.QtWidgets import QAbstractSpinBox, QPushButton, QComboBox, QToolButton -from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel +from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QApplication from PyQt5.QtCore import Qt, QObject, QEvent, QSize from PyQt5.QtGui import QIcon import copy +from functools import wraps +from typing import Callable def preventAnnoyingSpinboxScrollBehaviour(self, control: QAbstractSpinBox) -> None: @@ -119,3 +121,23 @@ def __init__(self, parent=None, info=None): self.setLayout(layout) # Semi-transparent background self.setStyleSheet("background-color: rgba(0, 0, 0, 80);") + + +def set_busy_cursor() -> None: + QApplication.setOverrideCursor(Qt.BusyCursor) + + +def unset_busy_cursor() -> None: + QApplication.restoreOverrideCursor() + + +def with_busy_cursor(func: Callable) -> Callable: + @wraps(func) + def wrapped(*args, **kwargs): + set_busy_cursor() + try: + return func(*args, **kwargs) + finally: + unset_busy_cursor() + + return wrapped From 1641a3904e4b1cdcd100162fe8553bd74584aaf4 Mon Sep 17 00:00:00 2001 From: michaellans Date: Thu, 2 Jul 2026 12:47:56 -0700 Subject: [PATCH 2/2] set busy cursor while env is loaded --- src/badger/gui/mini/pages/routine_page.py | 3 ++- src/badger/gui/windows/expandable_message_box.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/badger/gui/mini/pages/routine_page.py b/src/badger/gui/mini/pages/routine_page.py index f7ffaaff..50523b7d 100644 --- a/src/badger/gui/mini/pages/routine_page.py +++ b/src/badger/gui/mini/pages/routine_page.py @@ -58,7 +58,7 @@ from badger.gui.windows.review_dialog import BadgerReviewDialog from badger.gui.windows.add_random_dialog import BadgerAddRandomDialog from badger.gui.windows.message_dialog import BadgerScrollableMessageBox -from badger.gui.utils import filter_generator_config +from badger.gui.utils import filter_generator_config, with_busy_cursor from badger.environment import instantiate_env from badger.errors import ( BadgerEnvNotFoundError, @@ -1067,6 +1067,7 @@ def refresh_params_generator(self): except Exception as e: QMessageBox.warning(self, "Invalid script!", str(e)) + @with_busy_cursor def select_env(self, i: int): logger.info(f"Environment selected: {self.env_box.env_name} (index={i})") # Reset the initial table actions and ratio var ranges diff --git a/src/badger/gui/windows/expandable_message_box.py b/src/badger/gui/windows/expandable_message_box.py index cc887257..52b34eeb 100644 --- a/src/badger/gui/windows/expandable_message_box.py +++ b/src/badger/gui/windows/expandable_message_box.py @@ -12,6 +12,7 @@ ) from PyQt5.QtGui import QTextOption, QFont, QFontDatabase from PyQt5.QtCore import Qt +from badger.gui.utils import unset_busy_cursor class ExpandableMessageBox(QDialog): @@ -21,6 +22,8 @@ def __init__( super().__init__(parent) self.setWindowFlags(self.windowFlags() | Qt.WindowMaximizeButtonHint) + unset_busy_cursor() + # Main layout mainLayout = QVBoxLayout(self)