Skip to content

Commit

Permalink
New release 4.14: error dialog missing in commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
monofox committed Nov 8, 2016
1 parent c59a97d commit c4e53a0
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions errorlog.py
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)

0 comments on commit c4e53a0

Please sign in to comment.