-
Notifications
You must be signed in to change notification settings - Fork 0
/
final_dialog_box.py
64 lines (56 loc) · 2.53 KB
/
final_dialog_box.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
This file contains code from dialog_box.ui file with modifications.
When this file is called through the app, it is supplied with the dialog message
and title which is then displayed in the dialog box.
"""
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_dialog(object):
def setupUi(self, dialog, title, label):
dialog.setObjectName("dialog")
dialog.resize(615, 120)
dialog.setMinimumSize(QtCore.QSize(615, 120))
dialog.setMaximumSize(QtCore.QSize(615, 120))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("error.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
dialog.setWindowIcon(icon)
self.verticalLayout = QtWidgets.QVBoxLayout(dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.label = QtWidgets.QLabel(dialog)
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.pushButton = QtWidgets.QPushButton(dialog)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(dialog, title, label)
stylesheet = """
QDialog {
border-image: url("b4.png");
}
"""
dialog.setStyleSheet(stylesheet)
self.pushButton.clicked.connect(dialog.accept)
QtCore.QMetaObject.connectSlotsByName(dialog)
def retranslateUi(self, dialog, title, label):
_translate = QtCore.QCoreApplication.translate
dialog.setWindowTitle(_translate("dialog", "{}".format(title)))
self.label.setText(_translate("dialog", "{}".format(label)))
self.pushButton.setText(_translate("dialog", "OK"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
dialog = QtWidgets.QDialog()
ui = Ui_dialog()
ui.setupUi(dialog, 'change title', 'change label')
dialog.show()
sys.exit(app.exec_())