/
errormessagedialog.py
33 lines (26 loc) · 988 Bytes
/
errormessagedialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
from qt import pyqtSlot
from qt import QString
from qt import QStringListModel
from qt import QAbstractButton
from qt import QDialog
from qt import QDialogButtonBox
from ui.errormessagedialog import Ui_ErrorMessageDialog
class ErrorMessageDialog(QDialog):
def __init__(self, parent=None):
super(ErrorMessageDialog, self).__init__(parent)
self.ui = Ui_ErrorMessageDialog()
self.ui.setupUi(self)
self.model = QStringListModel(self)
self.ui.listView.setModel(self.model)
@pyqtSlot(QAbstractButton)
def on_buttonBox_clicked(self, button):
if button == self.ui.buttonBox.button(QDialogButtonBox.Close):
self.close()
elif button == self.ui.buttonBox.button(QDialogButtonBox.Reset):
self.model.setStringList([])
@pyqtSlot(QString)
def appendMessage(self, msg):
strs = self.model.stringList()
strs.append(msg)
self.model.setStringList(strs)