make primitive handler

This commit is contained in:
Dominik Demuth 2024-02-26 19:16:34 +01:00
parent 3932e47d13
commit e0ba48f900
3 changed files with 40 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,32 @@
import logging
from gui_qt.Qt import QtWidgets
from gui_qt.lib.codeeditor import EditorWidget
class ConsoleDock(QtWidgets.QDockWidget):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.code = EditorWidget(self)
self.code.editor.setReadOnly(True)
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)
if __name__ == "__main__":
app = QtWidgets.QApplication([])
w = ConsoleDock()
w.show()
app.exec()

View File

@ -12,6 +12,7 @@ from nmreval.lib.logger import logger
from nmreval.io.sessionwriter import NMRWriter
from .management import UpperManagement
from .console import ConsoleDock, QTextHandler
from ..Qt import QtGui, QtPrintSupport
from ..data.shift_graphs import QShift
from ..data.signaledit import QPreviewDialog, QBaselineDialog
@ -61,6 +62,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.fitresult_dialog = None
self.eval = None
self.editor = None
self.logtext = QTextHandler(self)
logger.addHandler(self.logtext)
self.addDockWidget(QtCore.Qt.DockWidgetArea.BottomDockWidgetArea, self.logtext.console)
self.movedialog = QMover(self)
@ -246,6 +251,8 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
filedialog.set_graphs(self.management.graphs.list())
raise ValueError('Test')
accepted = filedialog.exec()
if accepted:
fname = filedialog.selectedFiles()