-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New release 4.14: error dialog missing in commit.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = '<p style="color: #45BA02">[Info] %s: %s</p>' | ||
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 = '<p style="color: #C47C00">[Warning] %s: %s</p>' | ||
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 = '<p style="color: #D90000">[Error] %s: %s</p>' | ||
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 = '<p style="color: #0035A8"><pre>%s</pre></p>' | ||
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) |