Skip to content

Commit 8b6aca9

Browse files
committed
Add ability to set errorMessageColor with style sheets
1 parent 93222a5 commit 8b6aca9

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

preditor/gui/console.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from .. import debug, settings, stream
2222
from ..streamhandler_helper import StreamHandlerHelper
23+
from . import QtPropertyInit
2324
from .codehighlighter import CodeHighlighter
2425
from .completer import PythonCompleter
2526
from .suggest_path_quotes_dialog import SuggestPathQuotesDialog
@@ -28,8 +29,9 @@
2829
class ConsolePrEdit(QTextEdit):
2930
# Ensure the error prompt only shows up once.
3031
_errorPrompted = False
31-
# the color error messages are displayed in, can be set by stylesheets
32-
_errorMessageColor = QColor(Qt.red)
32+
# the color error messages are displayed in, can be set by style-sheets via:
33+
# `ConsolePrEdit {qproperty-errorMessageColor: rgb(0, 255, 0)}`
34+
errorMessageColor = QtPropertyInit('_errorMessageColor', QColor(Qt.red))
3335

3436
def __init__(self, parent):
3537
super(ConsolePrEdit, self).__init__(parent)
@@ -366,12 +368,6 @@ def completer(self):
366368
"""returns the completer instance that is associated with this editor"""
367369
return self._completer
368370

369-
def errorMessageColor(self):
370-
return self.__class__._errorMessageColor
371-
372-
def setErrorMessageColor(self, color):
373-
self.__class__._errorMessageColor = color
374-
375371
def foregroundColor(self):
376372
return self._foregroundColor
377373

@@ -835,7 +831,7 @@ def write(self, msg, error=False):
835831
if not error:
836832
charFormat.setForeground(self.stdoutColor())
837833
else:
838-
charFormat.setForeground(self.errorMessageColor())
834+
charFormat.setForeground(self.errorMessageColor)
839835
self.setCurrentCharFormat(charFormat)
840836

841837
# If showing Error Hyperlinks... Sometimes (when a syntax error, at least),

preditor/gui/errordialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def setText(self, exc_info):
5151
msg
5252
% {
5353
'text': self.traceback_msg.split('\n')[-2],
54-
'color': ConsolePrEdit._errorMessageColor.name(),
54+
'color': ConsolePrEdit.errorMessageColor.name(),
5555
}
5656
)
5757

0 commit comments

Comments
 (0)