forked from IPKM/nmreval
242-uncaught-exception (#252)
close issue #242 Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de> Reviewed-on: IPKM/nmreval#252
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
from .codeeditor import _make_textformats
|
||||
from ..Qt import QtWidgets, QtCore, QtGui
|
||||
from nmreval.configs import config_paths
|
||||
@ -113,3 +116,27 @@ class QLog(QtWidgets.QDialog):
|
||||
|
||||
for lines in text[-100:]:
|
||||
self.plainTextEdit.appendPlainText(lines[:-1])
|
||||
|
||||
|
||||
class ConsoleDock(QtWidgets.QDockWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
self.code = QtWidgets.QPlainTextEdit(parent)
|
||||
self.code.highlight = LogHighlighter(self.code.document())
|
||||
self.code.setReadOnly(True)
|
||||
self.code.setMaximumBlockCount(50)
|
||||
self.setWidget(self.code)
|
||||
|
||||
|
||||
class QTextHandler(logging.Handler):
|
||||
def __init__(self, parent):
|
||||
super().__init__()
|
||||
|
||||
self.console = ConsoleDock(parent)
|
||||
self.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
|
||||
|
||||
def emit(self, record):
|
||||
msg = self.format(record)
|
||||
self.console.code.appendPlainText(msg)
|
||||
self.console.show()
|
||||
|
@ -10,7 +10,7 @@ from ..Qt import QtGui, QtWidgets, QtCore
|
||||
@contextmanager
|
||||
def busy_cursor():
|
||||
try:
|
||||
cursor = QtGui.QCursor(QtCore.Qt.ForbiddenCursor)
|
||||
cursor = QtGui.QCursor(QtCore.Qt.CursorShape.ForbiddenCursor)
|
||||
QtWidgets.QApplication.setOverrideCursor(cursor)
|
||||
yield
|
||||
|
||||
|
Reference in New Issue
Block a user