From c4e53a04c86439582f9e54909bfefff311598d23 Mon Sep 17 00:00:00 2001 From: Lukas Schreiner Date: Tue, 8 Nov 2016 18:07:44 +0100 Subject: [PATCH] New release 4.14: error dialog missing in commit. --- errorlog.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 errorlog.py diff --git a/errorlog.py b/errorlog.py new file mode 100644 index 0000000..bd6e67f --- /dev/null +++ b/errorlog.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# -*- coding: utf8 -*- +# +# @author Lukas Schreiner +from PyQt5.QtWidgets import QDialog, QVBoxLayout, QPlainTextEdit, QDialogButtonBox +from PyQt5.QtGui import QIcon +from PyQt5.QtCore import pyqtSlot +import datetime + +class ErrorDialog(QDialog): + + def __init__(self, parent=None): + super().__init__(parent) + self.hasData = False + self.setupUi() + + @pyqtSlot(str) + def addInfo(self, msg): + self.hasData = True + msgfmt = '

[Info] %s: %s

' + dtm = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + self.logContent.appendHtml(msgfmt % (dtm, msg)) + + @pyqtSlot(str) + def addWarning(self, msg): + self.hasData = True + msgfmt = '

[Warning] %s: %s

' + dtm = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + self.logContent.appendHtml(msgfmt % (dtm, msg)) + + @pyqtSlot(str) + def addError(self, msg): + self.hasData = True + msgfmt = '

[Error] %s: %s

' + dtm = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + self.logContent.appendHtml(msgfmt % (dtm, msg)) + + @pyqtSlot(str) + def addData(self, msg): + self.hasData = True + msgfmt = '

%s

' + self.logContent.appendHtml(msgfmt % (msg,)) + + def cleanup(self): + self.logContent.clear() + + def setupUi(self): + self.setWindowTitle('Fehler-Log') + self.setWindowIcon(QIcon('fls_logo.ico')) + self.resize(800, 800) + + # layout + vlayout = QVBoxLayout() + + # Log Area + self.logContent = QPlainTextEdit() + self.logContent.setReadOnly(True) + vlayout.addWidget(self.logContent) + + # Button Box + buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) + buttonBox.accepted.connect(self.accept); + vlayout.addWidget(buttonBox) + + self.setLayout(vlayout)