Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/badger/gui/mini/pages/routine_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion src/badger/gui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/badger/gui/windows/expandable_message_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -21,6 +22,8 @@ def __init__(
super().__init__(parent)
self.setWindowFlags(self.windowFlags() | Qt.WindowMaximizeButtonHint)

unset_busy_cursor()

# Main layout
mainLayout = QVBoxLayout(self)

Expand Down
Loading