Skip to content

Commit

Permalink
add processing message state
Browse files Browse the repository at this point in the history
# Conflicts:
#	orangewidget/utils/messagewidget.py

# Conflicts:
#	orangewidget/utils/messagewidget.py
  • Loading branch information
payno committed Aug 12, 2024
1 parent afa0638 commit 5c9fdc2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions orangewidget/utils/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ class Information(MessageGroup):
bar_background = "#ceceff"
bar_icon = QStyle.SP_MessageBoxInformation

class Processing(MessageGroup):
"""Base class for groups of processing messages in widgets"""
severity = 0
icon_path = None
bar_background = "#ceceff"
bar_icon = QStyle.SP_MessageBoxInformation


def __init__(self):
super().__init__()
self.message_bar = None
Expand Down Expand Up @@ -416,3 +424,7 @@ def warning(self, text_or_id=None, text=None, shown=True):
def error(self, text_or_id=None, text=None, shown=True):
self._warn_obsolete(text_or_id, "error")
self.Error._add_general(text_or_id, text, shown)

def processing_info(self, text_or_id=None, text=None, shown=True):
self._warn_obsolete(text_or_id, "processing")
self.Processing._add_general(text_or_id, text, shown)
4 changes: 4 additions & 0 deletions orangewidget/utils/messagewidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class Severity(enum.IntEnum):
Warning = 2 # == QMessageBox.Warning
#: An error message severity.
Error = 3 # == QMessageBox.Critical
#: A processing
Processing = 0


class Message(
Expand Down Expand Up @@ -100,6 +102,7 @@ class Message(
Warning = Severity.Warning
#: Alias for :attr:`Severity.Error`
Error = Severity.Error
Processing = Severity.Processing

def __new__(cls, severity=Severity.Information, icon=QIcon(), text="",
informativeText="", detailedText="", textFormat=Qt.PlainText):
Expand Down Expand Up @@ -181,6 +184,7 @@ def standard_pixmap(severity):
Severity.Information: QStyle.SP_MessageBoxInformation,
Severity.Warning: QStyle.SP_MessageBoxWarning,
Severity.Error: QStyle.SP_MessageBoxCritical,
Severity.Processing: QStyle.SP_MessageBoxInformation,
}
return mapping[severity]

Expand Down
1 change: 1 addition & 0 deletions orangewidget/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Message:
Information = QStyle.SP_MessageBoxInformation
Warning = QStyle.SP_MessageBoxWarning
Critical = QStyle.SP_MessageBoxCritical
Processing = 0

def __init__(self, text, persistent_id, icon=None, moreurl=None):
assert isinstance(text, str)
Expand Down

0 comments on commit 5c9fdc2

Please sign in to comment.