├── Appendix.pdf
├── Chapter01
├── __pycache__
│ ├── demoLineEdit.cpython-35.pyc
│ └── demoRadioButton1.cpython-35.pyc
├── callCheckBox1.pyw
├── callCheckBox2.pyw
├── callLineEdit.pyw
├── callRadioButton1.pyw
├── callRadioButton2.pyw
├── demoCheckBox1.py
├── demoCheckBox2.py
├── demoCheckbox1.ui
├── demoCheckbox2.ui
├── demoLineEdit.py
├── demoLineEdit.ui
├── demoRadioButton1.py
├── demoRadioButton1.ui
├── demoRadioButton2.py
└── demoRadioButton2.ui
├── Chapter02
├── __pycache__
│ ├── demoComboBox.cpython-35.pyc
│ ├── demoComboBox1.cpython-35.pyc
│ ├── demoFontComboBox.cpython-35.pyc
│ ├── demoProgressBar.cpython-35.pyc
│ ├── demoSignalSlot1.cpython-35.pyc
│ └── demoSpinBox.cpython-35.pyc
├── callCalculator.pyw
├── callComboBox.pyw
├── callFontComboBox.pyw
├── callListWidget1.pyw
├── callListWidget2.pyw
├── callListWidget3.pyw
├── callListWidgetOp.pyw
├── callProgressBar.pyw
├── callScrollBar.pyw
├── calldemoSignalSlot1.pyw
├── calldemoSpinner.pyw
├── demoCalculator.py
├── demoCalculator.ui
├── demoComboBox.py
├── demoComboBox.ui
├── demoFontComboBox.py
├── demoFontComboBox.ui
├── demoListWidget1.py
├── demoListWidget1.ui
├── demoListWidget2.py
├── demoListWidget2.ui
├── demoListWidget3.py
├── demoListWidget3.ui
├── demoListWidgetOp.py
├── demoListWidgetOp.ui
├── demoProgressBar.py
├── demoProgressBar.ui
├── demoScrollBar.py
├── demoScrollBar.ui
├── demoSignalSlot1.py
├── demoSignalSlot1.ui
├── demoSpinBox.py
└── demoSpinBox.ui
├── Chapter03
├── DemoTableWidget.ui
├── callCalendar.pyw
├── callLCD.pyw
├── callTableWidget.pyw
├── computeRoomRent.pyw
├── demoCalendar.py
├── demoCalendar.ui
├── demoLCD.py
├── demoLCD.ui
├── demoTabWidget.py
├── reservehotel.py
└── reservehotel.ui
├── Chapter04
├── LineEditClass.py
├── LineEditClass.ui
├── callLineEditClass.pyw
├── callMultilevelInheritance.pyw
├── callMultipleInheritance.pyw
├── callSimpleInheritance.pyw
├── callStudentClass.pyw
├── demoMultilevelInheritance.py
├── demoMultilevelInheritance.ui
├── demoMultipleInheritance.py
├── demoMultipleInheritance.ui
├── demoSimpleInheritance.py
├── demoSimpleInheritance.ui
├── demoStudentClass.py
└── demoStudentClass.ui
├── Chapter05
├── callColorDialog.pyw
├── callFileDialog.pyw
├── callFontDialog.pyw
├── callInputDialog.pyw
├── demoColorDialog.py
├── demoColorDialog.ui
├── demoFileDialog.py
├── demoFileDialog.ui
├── demoFontDialog.py
├── demoFontDialog.ui
├── demoInputDialog.py
└── demoInputDialog.ui
├── Chapter07
├── callServer.pyw
├── demoBrowser.py
├── demoDockWidget.ui
├── demoMenuBar.py
└── demoTabWidget.ui
├── LICENSE
└── README.md
/Appendix.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Appendix.pdf
--------------------------------------------------------------------------------
/Chapter01/__pycache__/demoLineEdit.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter01/__pycache__/demoLineEdit.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter01/__pycache__/demoRadioButton1.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter01/__pycache__/demoRadioButton1.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter01/callCheckBox1.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog
4 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
5 | from PyQt5.QtCore import pyqtSlot
6 | from demoCheckBox1 import *
7 |
8 | class MyForm(QDialog):
9 | def __init__(self):
10 | super().__init__()
11 | self.ui = Ui_Dialog()
12 | self.ui.setupUi(self)
13 | self.ui.checkBoxCheese.stateChanged.connect(self.dispAmount)
14 | self.ui.checkBoxOlives.stateChanged.connect(self.dispAmount)
15 | self.ui.checkBoxSausages.stateChanged.connect(self.dispAmount)
16 | self.show()
17 |
18 | @pyqtSlot()
19 | def dispAmount(self):
20 | amount=10
21 | if self.ui.checkBoxCheese.isChecked()==True:
22 | amount=amount+1
23 | if self.ui.checkBoxOlives.isChecked()==True:
24 | amount=amount+1
25 | if self.ui.checkBoxSausages.isChecked()==True:
26 | amount=amount+2
27 | self.ui.labelAmount.setText("Total amount for pizza is "+str(amount))
28 |
29 | if __name__=="__main__":
30 | app = QApplication(sys.argv)
31 | w = MyForm()
32 | w.show()
33 | sys.exit(app.exec_())
34 |
--------------------------------------------------------------------------------
/Chapter01/callCheckBox2.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog
4 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
5 | from PyQt5.QtCore import pyqtSlot
6 | from demoCheckBox2 import *
7 |
8 | class MyForm(QDialog):
9 | def __init__(self):
10 | super().__init__()
11 | self.ui = Ui_Dialog()
12 | self.ui.setupUi(self)
13 | self.ui.checkBoxChoclateAlmond.stateChanged.connect(self.dispAmount)
14 | self.ui.checkBoxChoclateChips.stateChanged.connect(self.dispAmount)
15 | self.ui.checkBoxCookieDough.stateChanged.connect(self.dispAmount)
16 | self.ui.checkBoxRockyRoad.stateChanged.connect(self.dispAmount)
17 | self.ui.checkBoxCoffee.stateChanged.connect(self.dispAmount)
18 | self.ui.checkBoxSoda.stateChanged.connect(self.dispAmount)
19 | self.ui.checkBoxTea.stateChanged.connect(self.dispAmount)
20 |
21 | self.show()
22 |
23 | @pyqtSlot()
24 | def dispAmount(self):
25 | amount=0
26 | if self.ui.checkBoxChoclateAlmond.isChecked()==True:
27 | amount=amount+3
28 | if self.ui.checkBoxChoclateChips.isChecked()==True:
29 | amount=amount+4
30 | if self.ui.checkBoxCookieDough.isChecked()==True:
31 | amount=amount+2
32 | if self.ui.checkBoxRockyRoad.isChecked()==True:
33 | amount=amount+5
34 | if self.ui.checkBoxCoffee.isChecked()==True:
35 | amount=amount+2
36 | if self.ui.checkBoxSoda.isChecked()==True:
37 | amount=amount+3
38 | if self.ui.checkBoxTea.isChecked()==True:
39 | amount=amount+1
40 | self.ui.labelAmount.setText("Total amount is $"+str(amount))
41 |
42 | if __name__=="__main__":
43 | app = QApplication(sys.argv)
44 | w = MyForm()
45 | w.show()
46 | sys.exit(app.exec_())
47 |
--------------------------------------------------------------------------------
/Chapter01/callLineEdit.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoLineEdit import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
13 | self.show()
14 |
15 | def dispmessage(self):
16 | self.ui.labelResponse.setText("Hello "+self.ui.lineEditName.text())
17 |
18 | if __name__=="__main__":
19 | app = QApplication(sys.argv)
20 | w = MyForm()
21 | w.show()
22 | sys.exit(app.exec_())
23 |
--------------------------------------------------------------------------------
/Chapter01/callRadioButton1.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoRadioButton1 import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.radioButtonFirstClass.toggled.connect(self.dispFare)
13 | self.ui.radioButtonBusinessClass.toggled.connect(self.dispFare)
14 | self.ui.radioButtonEconomyClass.toggled.connect(self.dispFare)
15 | self.show()
16 |
17 | def dispFare(self):
18 | fare=0
19 | if self.ui.radioButtonFirstClass.isChecked()==True:
20 | fare=150
21 | if self.ui.radioButtonBusinessClass.isChecked()==True:
22 | fare=125
23 | if self.ui.radioButtonEconomyClass.isChecked()==True:
24 | fare=100
25 | self.ui.labelFare.setText("Air Fare is "+str(fare))
26 |
27 | if __name__=="__main__":
28 | app = QApplication(sys.argv)
29 | w = MyForm()
30 | w.show()
31 | sys.exit(app.exec_())
32 |
--------------------------------------------------------------------------------
/Chapter01/callRadioButton2.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoRadioButton2 import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.radioButtonMedium.toggled.connect(self.dispSelected)
13 | self.ui.radioButtonLarge.toggled.connect(self.dispSelected)
14 | self.ui.radioButtonXL.toggled.connect(self.dispSelected)
15 | self.ui.radioButtonXXL.toggled.connect(self.dispSelected)
16 | self.ui.radioButtonDebitCard.toggled.connect(self.dispSelected)
17 | self.ui.radioButtonNetBanking.toggled.connect(self.dispSelected)
18 | self.ui.radioButtonCashOnDelivery.toggled.connect(self.dispSelected)
19 | self.show()
20 |
21 | def dispSelected(self):
22 | selected1="";
23 | selected2=""
24 | if self.ui.radioButtonMedium.isChecked()==True:
25 | selected1="Medium"
26 | if self.ui.radioButtonLarge.isChecked()==True:
27 | selected1="Large"
28 | if self.ui.radioButtonXL.isChecked()==True:
29 | selected1="Extra Large"
30 | if self.ui.radioButtonXXL.isChecked()==True:
31 | selected1="Extra Extra Large"
32 | if self.ui.radioButtonDebitCard.isChecked()==True:
33 | selected2="Debit/Credit Card"
34 | if self.ui.radioButtonNetBanking.isChecked()==True:
35 | selected2="NetBanking"
36 | if self.ui.radioButtonCashOnDelivery.isChecked()==True:
37 | selected2="Cash On Delivery"
38 | self.ui.labelSelected.setText("Chosen shirt size is "+selected1+" and payment method as " + selected2)
39 |
40 | if __name__=="__main__":
41 | app = QApplication(sys.argv)
42 | w = MyForm()
43 | w.show()
44 | sys.exit(app.exec_())
45 |
--------------------------------------------------------------------------------
/Chapter01/demoCheckBox1.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoCheckBox1.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(503, 272)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(130, 0, 221, 31))
17 | font = QtGui.QFont()
18 | font.setPointSize(14)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.label_2 = QtWidgets.QLabel(Dialog)
22 | self.label_2.setGeometry(QtCore.QRect(20, 50, 251, 31))
23 | font = QtGui.QFont()
24 | font.setPointSize(14)
25 | self.label_2.setFont(font)
26 | self.label_2.setObjectName("label_2")
27 | self.checkBoxCheese = QtWidgets.QCheckBox(Dialog)
28 | self.checkBoxCheese.setGeometry(QtCore.QRect(270, 60, 191, 17))
29 | font = QtGui.QFont()
30 | font.setPointSize(14)
31 | self.checkBoxCheese.setFont(font)
32 | self.checkBoxCheese.setObjectName("checkBoxCheese")
33 | self.checkBoxOlives = QtWidgets.QCheckBox(Dialog)
34 | self.checkBoxOlives.setGeometry(QtCore.QRect(270, 90, 241, 21))
35 | font = QtGui.QFont()
36 | font.setPointSize(14)
37 | self.checkBoxOlives.setFont(font)
38 | self.checkBoxOlives.setObjectName("checkBoxOlives")
39 | self.checkBoxSausages = QtWidgets.QCheckBox(Dialog)
40 | self.checkBoxSausages.setGeometry(QtCore.QRect(270, 120, 231, 17))
41 | font = QtGui.QFont()
42 | font.setPointSize(14)
43 | self.checkBoxSausages.setFont(font)
44 | self.checkBoxSausages.setObjectName("checkBoxSausages")
45 | self.labelAmount = QtWidgets.QLabel(Dialog)
46 | self.labelAmount.setGeometry(QtCore.QRect(50, 190, 371, 20))
47 | font = QtGui.QFont()
48 | font.setPointSize(14)
49 | self.labelAmount.setFont(font)
50 | self.labelAmount.setObjectName("labelAmount")
51 |
52 | self.retranslateUi(Dialog)
53 | QtCore.QMetaObject.connectSlotsByName(Dialog)
54 |
55 | def retranslateUi(self, Dialog):
56 | _translate = QtCore.QCoreApplication.translate
57 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
58 | self.label.setText(_translate("Dialog", "Regular Pizza $10"))
59 | self.label_2.setText(_translate("Dialog", "Select your extra toppings"))
60 | self.checkBoxCheese.setText(_translate("Dialog", "Extra Cheese $1"))
61 | self.checkBoxOlives.setText(_translate("Dialog", "Extra Olives $1"))
62 | self.checkBoxSausages.setText(_translate("Dialog", "Extra Sausages $2"))
63 | self.labelAmount.setText(_translate("Dialog", "TextLabel"))
64 |
65 |
66 | if __name__ == "__main__":
67 | import sys
68 | app = QtWidgets.QApplication(sys.argv)
69 | Dialog = QtWidgets.QDialog()
70 | ui = Ui_Dialog()
71 | ui.setupUi(Dialog)
72 | Dialog.show()
73 | sys.exit(app.exec_())
74 |
75 |
--------------------------------------------------------------------------------
/Chapter01/demoCheckbox1.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 503
10 | 272
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 130
20 | 0
21 | 221
22 | 31
23 |
24 |
25 |
26 |
27 | 14
28 |
29 |
30 |
31 | Regular Pizza $10
32 |
33 |
34 |
35 |
36 |
37 | 20
38 | 50
39 | 251
40 | 31
41 |
42 |
43 |
44 |
45 | 14
46 |
47 |
48 |
49 | Select your extra toppings
50 |
51 |
52 |
53 |
54 |
55 | 270
56 | 60
57 | 191
58 | 17
59 |
60 |
61 |
62 |
63 | 14
64 |
65 |
66 |
67 | Extra Cheese $1
68 |
69 |
70 |
71 |
72 |
73 | 270
74 | 90
75 | 241
76 | 21
77 |
78 |
79 |
80 |
81 | 14
82 |
83 |
84 |
85 | Extra Olives $1
86 |
87 |
88 |
89 |
90 |
91 | 270
92 | 120
93 | 231
94 | 17
95 |
96 |
97 |
98 |
99 | 14
100 |
101 |
102 |
103 | Extra Sausages $2
104 |
105 |
106 |
107 |
108 |
109 | 50
110 | 190
111 | 371
112 | 20
113 |
114 |
115 |
116 |
117 | 14
118 |
119 |
120 |
121 | TextLabel
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/Chapter01/demoLineEdit.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoLineEdit.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(379, 195)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(6, 40, 121, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(11)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.labelResponse = QtWidgets.QLabel(Dialog)
22 | self.labelResponse.setGeometry(QtCore.QRect(40, 90, 271, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(11)
25 | self.labelResponse.setFont(font)
26 | self.labelResponse.setObjectName("labelResponse")
27 | self.lineEditName = QtWidgets.QLineEdit(Dialog)
28 | self.lineEditName.setGeometry(QtCore.QRect(140, 40, 201, 20))
29 | font = QtGui.QFont()
30 | font.setPointSize(11)
31 | self.lineEditName.setFont(font)
32 | self.lineEditName.setObjectName("lineEditName")
33 | self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
34 | self.ButtonClickMe.setGeometry(QtCore.QRect(160, 130, 101, 23))
35 | font = QtGui.QFont()
36 | font.setPointSize(11)
37 | self.ButtonClickMe.setFont(font)
38 | self.ButtonClickMe.setObjectName("ButtonClickMe")
39 |
40 | self.retranslateUi(Dialog)
41 | QtCore.QMetaObject.connectSlotsByName(Dialog)
42 |
43 | def retranslateUi(self, Dialog):
44 | _translate = QtCore.QCoreApplication.translate
45 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
46 | self.label.setText(_translate("Dialog", "Enter your name"))
47 | self.labelResponse.setText(_translate("Dialog", "TextLabel"))
48 | self.ButtonClickMe.setText(_translate("Dialog", "Click"))
49 |
50 |
--------------------------------------------------------------------------------
/Chapter01/demoLineEdit.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 379
10 | 195
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 6
20 | 40
21 | 121
22 | 20
23 |
24 |
25 |
26 |
27 | 11
28 |
29 |
30 |
31 | Enter your name
32 |
33 |
34 |
35 |
36 |
37 | 40
38 | 90
39 | 271
40 | 20
41 |
42 |
43 |
44 |
45 | 11
46 |
47 |
48 |
49 | TextLabel
50 |
51 |
52 |
53 |
54 |
55 | 140
56 | 40
57 | 201
58 | 20
59 |
60 |
61 |
62 |
63 | 11
64 |
65 |
66 |
67 |
68 |
69 |
70 | 160
71 | 130
72 | 101
73 | 23
74 |
75 |
76 |
77 |
78 | 11
79 |
80 |
81 |
82 | Click
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Chapter01/demoRadioButton1.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoRadioButton1.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(470, 290)
15 | self.radioButtonBusinessClass = QtWidgets.QRadioButton(Dialog)
16 | self.radioButtonBusinessClass.setGeometry(QtCore.QRect(30, 130, 251, 17))
17 | font = QtGui.QFont()
18 | font.setPointSize(14)
19 | self.radioButtonBusinessClass.setFont(font)
20 | self.radioButtonBusinessClass.setObjectName("radioButtonBusinessClass")
21 | self.radioButtonEconomyClass = QtWidgets.QRadioButton(Dialog)
22 | self.radioButtonEconomyClass.setGeometry(QtCore.QRect(30, 180, 221, 31))
23 | font = QtGui.QFont()
24 | font.setPointSize(14)
25 | self.radioButtonEconomyClass.setFont(font)
26 | self.radioButtonEconomyClass.setObjectName("radioButtonEconomyClass")
27 | self.radioButtonFirstClass = QtWidgets.QRadioButton(Dialog)
28 | self.radioButtonFirstClass.setGeometry(QtCore.QRect(30, 80, 201, 17))
29 | font = QtGui.QFont()
30 | font.setPointSize(14)
31 | self.radioButtonFirstClass.setFont(font)
32 | self.radioButtonFirstClass.setObjectName("radioButtonFirstClass")
33 | self.label = QtWidgets.QLabel(Dialog)
34 | self.label.setGeometry(QtCore.QRect(80, 10, 261, 31))
35 | font = QtGui.QFont()
36 | font.setPointSize(14)
37 | self.label.setFont(font)
38 | self.label.setObjectName("label")
39 | self.labelFare = QtWidgets.QLabel(Dialog)
40 | self.labelFare.setGeometry(QtCore.QRect(40, 245, 391, 21))
41 | font = QtGui.QFont()
42 | font.setPointSize(14)
43 | self.labelFare.setFont(font)
44 | self.labelFare.setText("")
45 | self.labelFare.setObjectName("labelFare")
46 |
47 | self.retranslateUi(Dialog)
48 | QtCore.QMetaObject.connectSlotsByName(Dialog)
49 |
50 | def retranslateUi(self, Dialog):
51 | _translate = QtCore.QCoreApplication.translate
52 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
53 | self.radioButtonBusinessClass.setText(_translate("Dialog", "Business Class $125"))
54 | self.radioButtonEconomyClass.setText(_translate("Dialog", "Economy Class $100"))
55 | self.radioButtonFirstClass.setText(_translate("Dialog", "First Class $150"))
56 | self.label.setText(_translate("Dialog", "Choose the flight type"))
57 |
58 |
59 | if __name__ == "__main__":
60 | import sys
61 | app = QtWidgets.QApplication(sys.argv)
62 | Dialog = QtWidgets.QDialog()
63 | ui = Ui_Dialog()
64 | ui.setupUi(Dialog)
65 | Dialog.show()
66 | sys.exit(app.exec_())
67 |
68 |
--------------------------------------------------------------------------------
/Chapter01/demoRadioButton1.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 470
10 | 290
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 30
20 | 130
21 | 251
22 | 17
23 |
24 |
25 |
26 |
27 | 14
28 |
29 |
30 |
31 | Business Class $125
32 |
33 |
34 |
35 |
36 |
37 | 30
38 | 180
39 | 221
40 | 31
41 |
42 |
43 |
44 |
45 | 14
46 |
47 |
48 |
49 | Economy Class $100
50 |
51 |
52 |
53 |
54 |
55 | 30
56 | 80
57 | 201
58 | 17
59 |
60 |
61 |
62 |
63 | 14
64 |
65 |
66 |
67 | First Class $150
68 |
69 |
70 |
71 |
72 |
73 | 80
74 | 10
75 | 261
76 | 31
77 |
78 |
79 |
80 |
81 | 14
82 |
83 |
84 |
85 | Choose the flight type
86 |
87 |
88 |
89 |
90 |
91 | 40
92 | 245
93 | 391
94 | 21
95 |
96 |
97 |
98 |
99 | 14
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/Chapter01/demoRadioButton2.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoRadioButton2.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(730, 452)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(100, 10, 221, 21))
17 | font = QtGui.QFont()
18 | font.setPointSize(14)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.label_2 = QtWidgets.QLabel(Dialog)
22 | self.label_2.setGeometry(QtCore.QRect(100, 210, 261, 41))
23 | font = QtGui.QFont()
24 | font.setPointSize(14)
25 | self.label_2.setFont(font)
26 | self.label_2.setObjectName("label_2")
27 | self.labelSelected = QtWidgets.QLabel(Dialog)
28 | self.labelSelected.setGeometry(QtCore.QRect(20, 380, 691, 41))
29 | font = QtGui.QFont()
30 | font.setPointSize(14)
31 | self.labelSelected.setFont(font)
32 | self.labelSelected.setText("")
33 | self.labelSelected.setObjectName("labelSelected")
34 | self.layoutWidget = QtWidgets.QWidget(Dialog)
35 | self.layoutWidget.setGeometry(QtCore.QRect(100, 50, 56, 128))
36 | self.layoutWidget.setObjectName("layoutWidget")
37 | self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
38 | self.verticalLayout.setContentsMargins(0, 0, 0, 0)
39 | self.verticalLayout.setObjectName("verticalLayout")
40 | self.radioButtonMedium = QtWidgets.QRadioButton(self.layoutWidget)
41 | font = QtGui.QFont()
42 | font.setPointSize(14)
43 | self.radioButtonMedium.setFont(font)
44 | self.radioButtonMedium.setObjectName("radioButtonMedium")
45 | self.verticalLayout.addWidget(self.radioButtonMedium)
46 | self.radioButtonLarge = QtWidgets.QRadioButton(self.layoutWidget)
47 | font = QtGui.QFont()
48 | font.setPointSize(14)
49 | self.radioButtonLarge.setFont(font)
50 | self.radioButtonLarge.setObjectName("radioButtonLarge")
51 | self.verticalLayout.addWidget(self.radioButtonLarge)
52 | self.radioButtonXL = QtWidgets.QRadioButton(self.layoutWidget)
53 | font = QtGui.QFont()
54 | font.setPointSize(14)
55 | self.radioButtonXL.setFont(font)
56 | self.radioButtonXL.setObjectName("radioButtonXL")
57 | self.verticalLayout.addWidget(self.radioButtonXL)
58 | self.radioButtonXXL = QtWidgets.QRadioButton(self.layoutWidget)
59 | font = QtGui.QFont()
60 | font.setPointSize(14)
61 | self.radioButtonXXL.setFont(font)
62 | self.radioButtonXXL.setObjectName("radioButtonXXL")
63 | self.verticalLayout.addWidget(self.radioButtonXXL)
64 | self.layoutWidget1 = QtWidgets.QWidget(Dialog)
65 | self.layoutWidget1.setGeometry(QtCore.QRect(100, 260, 170, 95))
66 | self.layoutWidget1.setObjectName("layoutWidget1")
67 | self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.layoutWidget1)
68 | self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
69 | self.verticalLayout_2.setObjectName("verticalLayout_2")
70 | self.radioButtonDebitCard = QtWidgets.QRadioButton(self.layoutWidget1)
71 | font = QtGui.QFont()
72 | font.setPointSize(14)
73 | self.radioButtonDebitCard.setFont(font)
74 | self.radioButtonDebitCard.setObjectName("radioButtonDebitCard")
75 | self.verticalLayout_2.addWidget(self.radioButtonDebitCard)
76 | self.radioButtonNetBanking = QtWidgets.QRadioButton(self.layoutWidget1)
77 | font = QtGui.QFont()
78 | font.setPointSize(14)
79 | self.radioButtonNetBanking.setFont(font)
80 | self.radioButtonNetBanking.setObjectName("radioButtonNetBanking")
81 | self.verticalLayout_2.addWidget(self.radioButtonNetBanking)
82 | self.radioButtonCashOnDelivery = QtWidgets.QRadioButton(self.layoutWidget1)
83 | font = QtGui.QFont()
84 | font.setPointSize(14)
85 | self.radioButtonCashOnDelivery.setFont(font)
86 | self.radioButtonCashOnDelivery.setObjectName("radioButtonCashOnDelivery")
87 | self.verticalLayout_2.addWidget(self.radioButtonCashOnDelivery)
88 |
89 | self.retranslateUi(Dialog)
90 | QtCore.QMetaObject.connectSlotsByName(Dialog)
91 |
92 | def retranslateUi(self, Dialog):
93 | _translate = QtCore.QCoreApplication.translate
94 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
95 | self.label.setText(_translate("Dialog", "Choose your Shirt Size"))
96 | self.label_2.setText(_translate("Dialog", "Choose your payment method"))
97 | self.radioButtonMedium.setText(_translate("Dialog", "M"))
98 | self.radioButtonLarge.setText(_translate("Dialog", "L"))
99 | self.radioButtonXL.setText(_translate("Dialog", "XL"))
100 | self.radioButtonXXL.setText(_translate("Dialog", "XXL"))
101 | self.radioButtonDebitCard.setText(_translate("Dialog", "Debit/Credit Card"))
102 | self.radioButtonNetBanking.setText(_translate("Dialog", "NetBanking"))
103 | self.radioButtonCashOnDelivery.setText(_translate("Dialog", "Cash On Delivery"))
104 |
105 |
--------------------------------------------------------------------------------
/Chapter01/demoRadioButton2.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 730
10 | 452
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 100
20 | 10
21 | 221
22 | 21
23 |
24 |
25 |
26 |
27 | 14
28 |
29 |
30 |
31 | Choose your Shirt Size
32 |
33 |
34 |
35 |
36 |
37 | 100
38 | 210
39 | 261
40 | 41
41 |
42 |
43 |
44 |
45 | 14
46 |
47 |
48 |
49 | Choose your payment method
50 |
51 |
52 |
53 |
54 |
55 | 20
56 | 380
57 | 691
58 | 41
59 |
60 |
61 |
62 |
63 | 14
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | 100
74 | 50
75 | 56
76 | 128
77 |
78 |
79 |
80 | -
81 |
82 |
83 |
84 | 14
85 |
86 |
87 |
88 | M
89 |
90 |
91 |
92 | -
93 |
94 |
95 |
96 | 14
97 |
98 |
99 |
100 | L
101 |
102 |
103 |
104 | -
105 |
106 |
107 |
108 | 14
109 |
110 |
111 |
112 | XL
113 |
114 |
115 |
116 | -
117 |
118 |
119 |
120 | 14
121 |
122 |
123 |
124 | XXL
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 | 100
134 | 260
135 | 170
136 | 95
137 |
138 |
139 |
140 | -
141 |
142 |
143 |
144 | 14
145 |
146 |
147 |
148 | Debit/Credit Card
149 |
150 |
151 |
152 | -
153 |
154 |
155 |
156 | 14
157 |
158 |
159 |
160 | NetBanking
161 |
162 |
163 |
164 | -
165 |
166 |
167 |
168 | 14
169 |
170 |
171 |
172 | Cash On Delivery
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/Chapter02/__pycache__/demoComboBox.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter02/__pycache__/demoComboBox.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter02/__pycache__/demoComboBox1.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter02/__pycache__/demoComboBox1.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter02/__pycache__/demoFontComboBox.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter02/__pycache__/demoFontComboBox.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter02/__pycache__/demoProgressBar.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter02/__pycache__/demoProgressBar.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter02/__pycache__/demoSignalSlot1.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter02/__pycache__/demoSignalSlot1.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter02/__pycache__/demoSpinBox.cpython-35.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Qt5-Python-GUI-Programming-Cookbook/2faa44cd090e4ef3a88c273bbf0bd7a3f4763dc0/Chapter02/__pycache__/demoSpinBox.cpython-35.pyc
--------------------------------------------------------------------------------
/Chapter02/callCalculator.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoCalculator import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.pushButtonPlus.clicked.connect(self.addtwonum)
13 | self.ui.pushButtonSubtract.clicked.connect(self.subtracttwonum)
14 | self.ui.pushButtonMultiply.clicked.connect(self.multiplytwonum)
15 | self.ui.pushButtonDivide.clicked.connect(self.dividetwonum)
16 | self.show()
17 |
18 | def addtwonum(self):
19 | if len(self.ui.lineEditFirstNumber.text())!=0:
20 | a=int(self.ui.lineEditFirstNumber.text())
21 | else:
22 | a=0
23 | if len(self.ui.lineEditSecondNumber.text())!=0:
24 | b=int(self.ui.lineEditSecondNumber.text())
25 | else:
26 | b=0
27 | sum=a+b
28 | self.ui.labelResult.setText("Addition: " +str(sum))
29 |
30 | def subtracttwonum(self):
31 | if len(self.ui.lineEditFirstNumber.text())!=0:
32 | a=int(self.ui.lineEditFirstNumber.text())
33 | else:
34 | a=0
35 | if len(self.ui.lineEditSecondNumber.text())!=0:
36 | b=int(self.ui.lineEditSecondNumber.text())
37 | else:
38 | b=0
39 | diff=a-b
40 | self.ui.labelResult.setText("Substraction: " +str(diff))
41 |
42 | def multiplytwonum(self):
43 | if len(self.ui.lineEditFirstNumber.text())!=0:
44 | a=int(self.ui.lineEditFirstNumber.text())
45 | else:
46 | a=0
47 | if len(self.ui.lineEditSecondNumber.text())!=0:
48 | b=int(self.ui.lineEditSecondNumber.text())
49 | else:
50 | b=0
51 | mult=a*b
52 | self.ui.labelResult.setText("Multiplication: " +str(mult))
53 |
54 | def dividetwonum(self):
55 | if len(self.ui.lineEditFirstNumber.text())!=0:
56 | a=int(self.ui.lineEditFirstNumber.text())
57 | else:
58 | a=0
59 | if len(self.ui.lineEditSecondNumber.text())!=0:
60 | b=int(self.ui.lineEditSecondNumber.text())
61 | else:
62 | b=0
63 | division=a/b
64 | self.ui.labelResult.setText("Division: " +str(round(division,2)))
65 |
66 | if __name__=="__main__":
67 | app = QApplication(sys.argv)
68 | w = MyForm()
69 | w.show()
70 | sys.exit(app.exec_())
71 |
--------------------------------------------------------------------------------
/Chapter02/callComboBox.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoComboBox import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.comboBoxAccountType.currentIndexChanged.connect(self.dispAccountType)
13 | self.show()
14 |
15 | def dispAccountType(self):
16 | self.ui.labelAccountType.setText("You have selected "+self.ui.comboBoxAccountType.itemText(self.ui.comboBoxAccountType.currentIndex()))
17 |
18 | if __name__=="__main__":
19 | app = QApplication(sys.argv)
20 | w = MyForm()
21 | w.show()
22 | sys.exit(app.exec_())
23 |
--------------------------------------------------------------------------------
/Chapter02/callFontComboBox.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoFontComboBox import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | myFont=QtGui.QFont(self.ui.fontComboBox.itemText(self.ui.fontComboBox.currentIndex()),15)
13 | self.ui.textEdit.setFont(myFont)
14 | self.ui.fontComboBox.currentFontChanged.connect(self.changeFont)
15 | self.show()
16 |
17 | def changeFont(self):
18 | myFont=QtGui.QFont(self.ui.fontComboBox.itemText(self.ui.fontComboBox.currentIndex()),15)
19 | self.ui.textEdit.setFont(myFont)
20 | if __name__=="__main__":
21 | app = QApplication(sys.argv)
22 | w = MyForm()
23 | w.show()
24 | sys.exit(app.exec_())
25 |
--------------------------------------------------------------------------------
/Chapter02/callListWidget1.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoListWidget1 import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.listWidgetDiagnosis.itemClicked.connect(self.dispSelectedTest)
13 | self.show()
14 |
15 | def dispSelectedTest(self):
16 | self.ui.labelTest.setText("You have selected "+self.ui.listWidgetDiagnosis.currentItem().text())
17 |
18 | if __name__=="__main__":
19 | app = QApplication(sys.argv)
20 | w = MyForm()
21 | w.show()
22 | sys.exit(app.exec_())
23 |
--------------------------------------------------------------------------------
/Chapter02/callListWidget2.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoListWidget2 import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.listWidgetDiagnosis.itemSelectionChanged.connect(self.dispSelectedTest)
13 | self.show()
14 |
15 | def dispSelectedTest(self):
16 | self.ui.listWidgetSelectedTests.clear()
17 | items = self.ui.listWidgetDiagnosis.selectedItems()
18 | x=[]
19 | for i in list(items):
20 | self.ui.listWidgetSelectedTests.addItem(i.text())
21 | x.append(str(i.text()))
22 |
23 | if __name__=="__main__":
24 | app = QApplication(sys.argv)
25 | w = MyForm()
26 | w.show()
27 | sys.exit(app.exec_())
28 |
--------------------------------------------------------------------------------
/Chapter02/callListWidget3.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoListWidget3 import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.pushButtonAdd.clicked.connect(self.addlist)
13 | self.show()
14 |
15 | def addlist(self):
16 | self.ui.listWidgetSelectedItems.addItem(self.ui.lineEditFoodItem.text())
17 | self.ui.lineEditFoodItem.setText('')
18 | self.ui.lineEditFoodItem.setFocus()
19 |
20 | if __name__=="__main__":
21 | app = QApplication(sys.argv)
22 | w = MyForm()
23 | w.show()
24 | sys.exit(app.exec_())
25 |
--------------------------------------------------------------------------------
/Chapter02/callListWidgetOp.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication, QInputDialog, QListWidgetItem
4 |
5 | from demoListWidgetOp import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.listWidget.addItem('Ice Cream')
13 | self.ui.listWidget.addItem('Soda')
14 | self.ui.listWidget.addItem('Coffee')
15 | self.ui.listWidget.addItem('Chocolate')
16 | self.ui.pushButtonAdd.clicked.connect(self.addlist)
17 | self.ui.pushButtonEdit.clicked.connect(self.editlist)
18 | self.ui.pushButtonDelete.clicked.connect(self.delitem)
19 | self.ui.pushButtonDeleteAll.clicked.connect(self.delallitems)
20 | self.show()
21 |
22 | def addlist(self):
23 | self.ui.listWidget.addItem(self.ui.lineEdit.text())
24 | self.ui.lineEdit.setText('')
25 | self.ui.lineEdit.setFocus()
26 |
27 | def editlist(self):
28 | row=self.ui.listWidget.currentRow()
29 | newtext, ok=QInputDialog.getText(self, "Enter new text", "Enter new text")
30 | if ok and (len(newtext) !=0):
31 | self.ui.listWidget.takeItem(self.ui.listWidget.currentRow())
32 | self.ui.listWidget.insertItem(row,QListWidgetItem(newtext))
33 |
34 | def delitem(self):
35 | self.ui.listWidget.takeItem(self.ui.listWidget.currentRow())
36 |
37 | def delallitems(self):
38 | self.ui.listWidget.clear()
39 |
40 |
41 | if __name__=="__main__":
42 | app = QApplication(sys.argv)
43 | w = MyForm()
44 | w.show()
45 | sys.exit(app.exec_())
46 |
--------------------------------------------------------------------------------
/Chapter02/callProgressBar.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoProgressBar import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.pushButtonStart.clicked.connect(self.updateBar)
13 | self.show()
14 |
15 | def updateBar(self):
16 | x = 0
17 | while x < 100:
18 | x += 0.0001
19 | self.ui.progressBar.setValue(x)
20 |
21 | if __name__=="__main__":
22 | app = QApplication(sys.argv)
23 | w = MyForm()
24 | w.show()
25 | sys.exit(app.exec_())
26 |
--------------------------------------------------------------------------------
/Chapter02/callScrollBar.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoScrollBar import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.horizontalScrollBarSugarLevel.valueChanged.connect(self.scrollhorizontal)
13 | self.ui.verticalScrollBarPulseRate.valueChanged.connect(self.scrollvertical)
14 | self.ui.horizontalSliderBloodPressure.valueChanged.connect(self.sliderhorizontal)
15 | self.ui.verticalSliderCholestrolLevel.valueChanged.connect(self.slidervertical)
16 | self.show()
17 |
18 | def scrollhorizontal(self,value):
19 | self.ui.lineEditResult.setText("Sugar Level : "+str(value))
20 |
21 | def scrollvertical(self, value):
22 | self.ui.lineEditResult.setText("Pulse Rate : "+str(value))
23 |
24 | def sliderhorizontal(self, value):
25 | self.ui.lineEditResult.setText("Blood Pressure : "+str(value))
26 |
27 | def slidervertical(self, value):
28 | self.ui.lineEditResult.setText("Cholestrol Level : "+str(value))
29 |
30 |
31 | if __name__=="__main__":
32 | app = QApplication(sys.argv)
33 | w = MyForm()
34 | w.show()
35 | sys.exit(app.exec_())
36 |
--------------------------------------------------------------------------------
/Chapter02/calldemoSignalSlot1.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoSignalSlot1 import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.show()
13 |
14 | if __name__=="__main__":
15 | app = QApplication(sys.argv)
16 | w = MyForm()
17 | w.show()
18 | sys.exit(app.exec_())
19 |
--------------------------------------------------------------------------------
/Chapter02/calldemoSpinner.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoSpinBox import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.spinBoxBookQty.editingFinished.connect(self.result1)
13 | self.ui.doubleSpinBoxSugarWeight.editingFinished.connect(self.result2)
14 | self.show()
15 |
16 | def result1(self):
17 | if len(self.ui.lineEditBookPrice.text())!=0:
18 | bookPrice=int(self.ui.lineEditBookPrice.text())
19 | else:
20 | bookPrice=0
21 | totalBookAmount=self.ui.spinBoxBookQty.value() * bookPrice
22 | self.ui.lineEditBookAmount.setText(str(totalBookAmount))
23 |
24 | def result2(self):
25 | if len(self.ui.lineEditSugarPrice.text())!=0:
26 | sugarPrice=float(self.ui.lineEditSugarPrice.text())
27 | else:
28 | sugarPrice=0
29 | totalSugarAmount=self.ui.doubleSpinBoxSugarWeight.value() * sugarPrice
30 | self.ui.lineEditSugarAmount.setText(str(round(totalSugarAmount,2)))
31 | totalBookAmount=int(self.ui.lineEditBookAmount.text())
32 | totalAmount=totalBookAmount+totalSugarAmount
33 | self.ui.labelTotalAmount.setText(str(round(totalAmount,2)))
34 |
35 | if __name__=="__main__":
36 | app = QApplication(sys.argv)
37 | w = MyForm()
38 | w.show()
39 | sys.exit(app.exec_())
40 |
--------------------------------------------------------------------------------
/Chapter02/demoCalculator.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoCalculator.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(427, 269)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(10, 30, 161, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(12)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.label_2 = QtWidgets.QLabel(Dialog)
22 | self.label_2.setGeometry(QtCore.QRect(10, 80, 151, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(12)
25 | self.label_2.setFont(font)
26 | self.label_2.setObjectName("label_2")
27 | self.lineEditFirstNumber = QtWidgets.QLineEdit(Dialog)
28 | self.lineEditFirstNumber.setGeometry(QtCore.QRect(180, 30, 181, 20))
29 | font = QtGui.QFont()
30 | font.setPointSize(12)
31 | self.lineEditFirstNumber.setFont(font)
32 | self.lineEditFirstNumber.setObjectName("lineEditFirstNumber")
33 | self.lineEditSecondNumber = QtWidgets.QLineEdit(Dialog)
34 | self.lineEditSecondNumber.setGeometry(QtCore.QRect(180, 80, 181, 21))
35 | font = QtGui.QFont()
36 | font.setPointSize(12)
37 | self.lineEditSecondNumber.setFont(font)
38 | self.lineEditSecondNumber.setObjectName("lineEditSecondNumber")
39 | self.pushButtonPlus = QtWidgets.QPushButton(Dialog)
40 | self.pushButtonPlus.setGeometry(QtCore.QRect(20, 150, 71, 31))
41 | font = QtGui.QFont()
42 | font.setPointSize(12)
43 | self.pushButtonPlus.setFont(font)
44 | self.pushButtonPlus.setObjectName("pushButtonPlus")
45 | self.pushButtonSubtract = QtWidgets.QPushButton(Dialog)
46 | self.pushButtonSubtract.setGeometry(QtCore.QRect(120, 150, 75, 31))
47 | font = QtGui.QFont()
48 | font.setPointSize(12)
49 | self.pushButtonSubtract.setFont(font)
50 | self.pushButtonSubtract.setObjectName("pushButtonSubtract")
51 | self.pushButtonMultiply = QtWidgets.QPushButton(Dialog)
52 | self.pushButtonMultiply.setGeometry(QtCore.QRect(220, 150, 81, 31))
53 | font = QtGui.QFont()
54 | font.setPointSize(12)
55 | self.pushButtonMultiply.setFont(font)
56 | self.pushButtonMultiply.setObjectName("pushButtonMultiply")
57 | self.pushButtonDivide = QtWidgets.QPushButton(Dialog)
58 | self.pushButtonDivide.setGeometry(QtCore.QRect(330, 150, 75, 31))
59 | font = QtGui.QFont()
60 | font.setPointSize(12)
61 | self.pushButtonDivide.setFont(font)
62 | self.pushButtonDivide.setObjectName("pushButtonDivide")
63 | self.labelResult = QtWidgets.QLabel(Dialog)
64 | self.labelResult.setGeometry(QtCore.QRect(30, 210, 351, 16))
65 | font = QtGui.QFont()
66 | font.setPointSize(12)
67 | self.labelResult.setFont(font)
68 | self.labelResult.setText("")
69 | self.labelResult.setObjectName("labelResult")
70 |
71 | self.retranslateUi(Dialog)
72 | QtCore.QMetaObject.connectSlotsByName(Dialog)
73 |
74 | def retranslateUi(self, Dialog):
75 | _translate = QtCore.QCoreApplication.translate
76 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
77 | self.label.setText(_translate("Dialog", "Enter first number"))
78 | self.label_2.setText(_translate("Dialog", "Enter second number"))
79 | self.pushButtonPlus.setText(_translate("Dialog", "+"))
80 | self.pushButtonSubtract.setText(_translate("Dialog", "-"))
81 | self.pushButtonMultiply.setText(_translate("Dialog", "X"))
82 | self.pushButtonDivide.setText(_translate("Dialog", "/"))
83 |
84 |
--------------------------------------------------------------------------------
/Chapter02/demoCalculator.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 427
10 | 269
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 30
21 | 161
22 | 20
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | Enter first number
32 |
33 |
34 |
35 |
36 |
37 | 10
38 | 80
39 | 151
40 | 20
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 | Enter second number
50 |
51 |
52 |
53 |
54 |
55 | 180
56 | 30
57 | 181
58 | 20
59 |
60 |
61 |
62 |
63 | 12
64 |
65 |
66 |
67 |
68 |
69 |
70 | 180
71 | 80
72 | 181
73 | 21
74 |
75 |
76 |
77 |
78 | 12
79 |
80 |
81 |
82 |
83 |
84 |
85 | 20
86 | 150
87 | 71
88 | 31
89 |
90 |
91 |
92 |
93 | 12
94 |
95 |
96 |
97 | +
98 |
99 |
100 |
101 |
102 |
103 | 120
104 | 150
105 | 75
106 | 31
107 |
108 |
109 |
110 |
111 | 12
112 |
113 |
114 |
115 | -
116 |
117 |
118 |
119 |
120 |
121 | 220
122 | 150
123 | 81
124 | 31
125 |
126 |
127 |
128 |
129 | 12
130 |
131 |
132 |
133 | X
134 |
135 |
136 |
137 |
138 |
139 | 330
140 | 150
141 | 75
142 | 31
143 |
144 |
145 |
146 |
147 | 12
148 |
149 |
150 |
151 | /
152 |
153 |
154 |
155 |
156 |
157 | 30
158 | 210
159 | 351
160 | 16
161 |
162 |
163 |
164 |
165 | 12
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
--------------------------------------------------------------------------------
/Chapter02/demoComboBox.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoComboBox.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(674, 200)
15 | self.comboBoxAccountType = QtWidgets.QComboBox(Dialog)
16 | self.comboBoxAccountType.setGeometry(QtCore.QRect(260, 40, 361, 31))
17 | font = QtGui.QFont()
18 | font.setPointSize(14)
19 | self.comboBoxAccountType.setFont(font)
20 | self.comboBoxAccountType.setObjectName("comboBoxAccountType")
21 | self.comboBoxAccountType.addItem("")
22 | self.comboBoxAccountType.addItem("")
23 | self.comboBoxAccountType.addItem("")
24 | self.comboBoxAccountType.addItem("")
25 | self.label = QtWidgets.QLabel(Dialog)
26 | self.label.setGeometry(QtCore.QRect(20, 40, 231, 31))
27 | font = QtGui.QFont()
28 | font.setPointSize(14)
29 | self.label.setFont(font)
30 | self.label.setObjectName("label")
31 | self.labelAccountType = QtWidgets.QLabel(Dialog)
32 | self.labelAccountType.setGeometry(QtCore.QRect(40, 110, 581, 41))
33 | font = QtGui.QFont()
34 | font.setPointSize(14)
35 | self.labelAccountType.setFont(font)
36 | self.labelAccountType.setText("")
37 | self.labelAccountType.setObjectName("labelAccountType")
38 |
39 | self.retranslateUi(Dialog)
40 | QtCore.QMetaObject.connectSlotsByName(Dialog)
41 |
42 | def retranslateUi(self, Dialog):
43 | _translate = QtCore.QCoreApplication.translate
44 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
45 | self.comboBoxAccountType.setItemText(0, _translate("Dialog", "Saving Account"))
46 | self.comboBoxAccountType.setItemText(1, _translate("Dialog", "Current Account"))
47 | self.comboBoxAccountType.setItemText(2, _translate("Dialog", "Recurring Deposit Account"))
48 | self.comboBoxAccountType.setItemText(3, _translate("Dialog", "Fixed Deposit Account"))
49 | self.label.setText(_translate("Dialog", "Select your account type"))
50 |
51 |
52 | if __name__ == "__main__":
53 | import sys
54 | app = QtWidgets.QApplication(sys.argv)
55 | Dialog = QtWidgets.QDialog()
56 | ui = Ui_Dialog()
57 | ui.setupUi(Dialog)
58 | Dialog.show()
59 | sys.exit(app.exec_())
60 |
61 |
--------------------------------------------------------------------------------
/Chapter02/demoComboBox.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 674
10 | 200
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 260
20 | 40
21 | 361
22 | 31
23 |
24 |
25 |
26 |
27 | 14
28 |
29 |
30 | -
31 |
32 | Saving Account
33 |
34 |
35 | -
36 |
37 | Current Account
38 |
39 |
40 | -
41 |
42 | Recurring Deposit Account
43 |
44 |
45 | -
46 |
47 | Fixed Deposit Account
48 |
49 |
50 |
51 |
52 |
53 |
54 | 20
55 | 40
56 | 231
57 | 31
58 |
59 |
60 |
61 |
62 | 14
63 |
64 |
65 |
66 | Select your account type
67 |
68 |
69 |
70 |
71 |
72 | 40
73 | 110
74 | 581
75 | 41
76 |
77 |
78 |
79 |
80 | 14
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/Chapter02/demoFontComboBox.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoFontComboBox.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(560, 228)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(20, 20, 231, 41))
17 | font = QtGui.QFont()
18 | font.setPointSize(14)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.labelTextLine = QtWidgets.QLabel(Dialog)
22 | self.labelTextLine.setGeometry(QtCore.QRect(20, 60, 161, 41))
23 | font = QtGui.QFont()
24 | font.setPointSize(14)
25 | self.labelTextLine.setFont(font)
26 | self.labelTextLine.setObjectName("labelTextLine")
27 | self.fontComboBox = QtWidgets.QFontComboBox(Dialog)
28 | self.fontComboBox.setGeometry(QtCore.QRect(200, 20, 321, 31))
29 | font = QtGui.QFont()
30 | font.setPointSize(14)
31 | self.fontComboBox.setFont(font)
32 | self.fontComboBox.setObjectName("fontComboBox")
33 | self.textEdit = QtWidgets.QTextEdit(Dialog)
34 | self.textEdit.setGeometry(QtCore.QRect(200, 70, 321, 121))
35 | self.textEdit.setObjectName("textEdit")
36 |
37 | self.retranslateUi(Dialog)
38 | QtCore.QMetaObject.connectSlotsByName(Dialog)
39 |
40 | def retranslateUi(self, Dialog):
41 | _translate = QtCore.QCoreApplication.translate
42 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
43 | self.label.setText(_translate("Dialog", "Select desired font"))
44 | self.labelTextLine.setText(_translate("Dialog", "Type some text"))
45 |
46 |
47 | if __name__ == "__main__":
48 | import sys
49 | app = QtWidgets.QApplication(sys.argv)
50 | Dialog = QtWidgets.QDialog()
51 | ui = Ui_Dialog()
52 | ui.setupUi(Dialog)
53 | Dialog.show()
54 | sys.exit(app.exec_())
55 |
56 |
--------------------------------------------------------------------------------
/Chapter02/demoFontComboBox.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 552
10 | 228
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 20
21 | 231
22 | 41
23 |
24 |
25 |
26 |
27 | 14
28 |
29 |
30 |
31 | Select desired font
32 |
33 |
34 |
35 |
36 |
37 | 20
38 | 60
39 | 161
40 | 41
41 |
42 |
43 |
44 |
45 | 14
46 |
47 |
48 |
49 | Type some text
50 |
51 |
52 |
53 |
54 |
55 | 200
56 | 20
57 | 321
58 | 31
59 |
60 |
61 |
62 |
63 | 14
64 |
65 |
66 |
67 |
68 |
69 |
70 | 200
71 | 70
72 | 321
73 | 121
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidget1.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoListWidget1.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(686, 287)
15 | self.listWidgetDiagnosis = QtWidgets.QListWidget(Dialog)
16 | self.listWidgetDiagnosis.setGeometry(QtCore.QRect(280, 20, 351, 171))
17 | font = QtGui.QFont()
18 | font.setPointSize(14)
19 | self.listWidgetDiagnosis.setFont(font)
20 | self.listWidgetDiagnosis.setObjectName("listWidgetDiagnosis")
21 | item = QtWidgets.QListWidgetItem()
22 | self.listWidgetDiagnosis.addItem(item)
23 | item = QtWidgets.QListWidgetItem()
24 | self.listWidgetDiagnosis.addItem(item)
25 | item = QtWidgets.QListWidgetItem()
26 | self.listWidgetDiagnosis.addItem(item)
27 | item = QtWidgets.QListWidgetItem()
28 | self.listWidgetDiagnosis.addItem(item)
29 | item = QtWidgets.QListWidgetItem()
30 | self.listWidgetDiagnosis.addItem(item)
31 | self.labelTest = QtWidgets.QLabel(Dialog)
32 | self.labelTest.setGeometry(QtCore.QRect(40, 230, 621, 31))
33 | font = QtGui.QFont()
34 | font.setPointSize(14)
35 | self.labelTest.setFont(font)
36 | self.labelTest.setText("")
37 | self.labelTest.setObjectName("labelTest")
38 | self.label = QtWidgets.QLabel(Dialog)
39 | self.label.setGeometry(QtCore.QRect(30, 10, 241, 31))
40 | font = QtGui.QFont()
41 | font.setPointSize(14)
42 | self.label.setFont(font)
43 | self.label.setObjectName("label")
44 |
45 | self.retranslateUi(Dialog)
46 | QtCore.QMetaObject.connectSlotsByName(Dialog)
47 |
48 | def retranslateUi(self, Dialog):
49 | _translate = QtCore.QCoreApplication.translate
50 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
51 | __sortingEnabled = self.listWidgetDiagnosis.isSortingEnabled()
52 | self.listWidgetDiagnosis.setSortingEnabled(False)
53 | item = self.listWidgetDiagnosis.item(0)
54 | item.setText(_translate("Dialog", "Urine Analaysis $5"))
55 | item = self.listWidgetDiagnosis.item(1)
56 | item.setText(_translate("Dialog", "Chest X Ray 100$"))
57 | item = self.listWidgetDiagnosis.item(2)
58 | item.setText(_translate("Dialog", "Sugar Level test $3"))
59 | item = self.listWidgetDiagnosis.item(3)
60 | item.setText(_translate("Dialog", "Hemoglobin test $7"))
61 | item = self.listWidgetDiagnosis.item(4)
62 | item.setText(_translate("Dialog", "Thyroid Stimulating Harmone test $10"))
63 | self.listWidgetDiagnosis.setSortingEnabled(__sortingEnabled)
64 | self.label.setText(_translate("Dialog", "Choose the Diagnosis Tests"))
65 |
66 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidget1.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 686
10 | 287
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 280
20 | 20
21 | 351
22 | 171
23 |
24 |
25 |
26 |
27 | 14
28 |
29 |
30 | -
31 |
32 | Urine Analaysis $5
33 |
34 |
35 | -
36 |
37 | Chest X Ray 100$
38 |
39 |
40 | -
41 |
42 | Sugar Level test $3
43 |
44 |
45 | -
46 |
47 | Hemoglobin test $7
48 |
49 |
50 | -
51 |
52 | Thyroid Stimulating Harmone test $10
53 |
54 |
55 |
56 |
57 |
58 |
59 | 40
60 | 230
61 | 621
62 | 31
63 |
64 |
65 |
66 |
67 | 14
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | 30
78 | 10
79 | 241
80 | 31
81 |
82 |
83 |
84 |
85 | 14
86 |
87 |
88 |
89 | Choose the Diagnosis Tests
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidget2.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoListWidget2.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(729, 412)
15 | self.listWidgetDiagnosis = QtWidgets.QListWidget(Dialog)
16 | self.listWidgetDiagnosis.setGeometry(QtCore.QRect(200, 20, 351, 171))
17 | font = QtGui.QFont()
18 | font.setPointSize(14)
19 | self.listWidgetDiagnosis.setFont(font)
20 | self.listWidgetDiagnosis.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
21 | self.listWidgetDiagnosis.setObjectName("listWidgetDiagnosis")
22 | item = QtWidgets.QListWidgetItem()
23 | self.listWidgetDiagnosis.addItem(item)
24 | item = QtWidgets.QListWidgetItem()
25 | self.listWidgetDiagnosis.addItem(item)
26 | item = QtWidgets.QListWidgetItem()
27 | self.listWidgetDiagnosis.addItem(item)
28 | item = QtWidgets.QListWidgetItem()
29 | self.listWidgetDiagnosis.addItem(item)
30 | item = QtWidgets.QListWidgetItem()
31 | self.listWidgetDiagnosis.addItem(item)
32 | self.labelTest = QtWidgets.QLabel(Dialog)
33 | self.labelTest.setGeometry(QtCore.QRect(20, 230, 171, 31))
34 | font = QtGui.QFont()
35 | font.setPointSize(14)
36 | self.labelTest.setFont(font)
37 | self.labelTest.setObjectName("labelTest")
38 | self.label = QtWidgets.QLabel(Dialog)
39 | self.label.setGeometry(QtCore.QRect(30, 10, 151, 31))
40 | font = QtGui.QFont()
41 | font.setPointSize(14)
42 | self.label.setFont(font)
43 | self.label.setObjectName("label")
44 | self.listWidgetSelectedTests = QtWidgets.QListWidget(Dialog)
45 | self.listWidgetSelectedTests.setGeometry(QtCore.QRect(200, 220, 351, 192))
46 | font = QtGui.QFont()
47 | font.setPointSize(14)
48 | self.listWidgetSelectedTests.setFont(font)
49 | self.listWidgetSelectedTests.setObjectName("listWidgetSelectedTests")
50 |
51 | self.retranslateUi(Dialog)
52 | QtCore.QMetaObject.connectSlotsByName(Dialog)
53 |
54 | def retranslateUi(self, Dialog):
55 | _translate = QtCore.QCoreApplication.translate
56 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
57 | __sortingEnabled = self.listWidgetDiagnosis.isSortingEnabled()
58 | self.listWidgetDiagnosis.setSortingEnabled(False)
59 | item = self.listWidgetDiagnosis.item(0)
60 | item.setText(_translate("Dialog", "Urine Analaysis $5"))
61 | item = self.listWidgetDiagnosis.item(1)
62 | item.setText(_translate("Dialog", "Chest X Ray 100$"))
63 | item = self.listWidgetDiagnosis.item(2)
64 | item.setText(_translate("Dialog", "Sugar Level test $3"))
65 | item = self.listWidgetDiagnosis.item(3)
66 | item.setText(_translate("Dialog", "Hemoglobin test $7"))
67 | item = self.listWidgetDiagnosis.item(4)
68 | item.setText(_translate("Dialog", "Thyroid Stimulating Harmone test $10"))
69 | self.listWidgetDiagnosis.setSortingEnabled(__sortingEnabled)
70 | self.labelTest.setText(_translate("Dialog", "Selected tests are"))
71 | self.label.setText(_translate("Dialog", "Diagnosis Tests"))
72 |
73 |
74 | if __name__ == "__main__":
75 | import sys
76 | app = QtWidgets.QApplication(sys.argv)
77 | Dialog = QtWidgets.QDialog()
78 | ui = Ui_Dialog()
79 | ui.setupUi(Dialog)
80 | Dialog.show()
81 | sys.exit(app.exec_())
82 |
83 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidget2.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 729
10 | 412
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 200
20 | 20
21 | 351
22 | 171
23 |
24 |
25 |
26 |
27 | 14
28 |
29 |
30 |
31 | QAbstractItemView::MultiSelection
32 |
33 | -
34 |
35 | Urine Analaysis $5
36 |
37 |
38 | -
39 |
40 | Chest X Ray 100$
41 |
42 |
43 | -
44 |
45 | Sugar Level test $3
46 |
47 |
48 | -
49 |
50 | Hemoglobin test $7
51 |
52 |
53 | -
54 |
55 | Thyroid Stimulating Harmone test $10
56 |
57 |
58 |
59 |
60 |
61 |
62 | 20
63 | 230
64 | 171
65 | 31
66 |
67 |
68 |
69 |
70 | 14
71 |
72 |
73 |
74 | Selected tests are
75 |
76 |
77 |
78 |
79 |
80 | 30
81 | 10
82 | 151
83 | 31
84 |
85 |
86 |
87 |
88 | 14
89 |
90 |
91 |
92 | Diagnosis Tests
93 |
94 |
95 |
96 |
97 |
98 | 200
99 | 220
100 | 351
101 | 192
102 |
103 |
104 |
105 |
106 | 14
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidget3.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoListWidget3.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(734, 270)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(20, 20, 191, 16))
17 | font = QtGui.QFont()
18 | font.setPointSize(12)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.lineEditFoodItem = QtWidgets.QLineEdit(Dialog)
22 | self.lineEditFoodItem.setGeometry(QtCore.QRect(210, 20, 201, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(12)
25 | self.lineEditFoodItem.setFont(font)
26 | self.lineEditFoodItem.setObjectName("lineEditFoodItem")
27 | self.pushButtonAdd = QtWidgets.QPushButton(Dialog)
28 | self.pushButtonAdd.setGeometry(QtCore.QRect(110, 72, 111, 31))
29 | font = QtGui.QFont()
30 | font.setPointSize(12)
31 | self.pushButtonAdd.setFont(font)
32 | self.pushButtonAdd.setObjectName("pushButtonAdd")
33 | self.listWidgetSelectedItems = QtWidgets.QListWidget(Dialog)
34 | self.listWidgetSelectedItems.setGeometry(QtCore.QRect(430, 20, 256, 221))
35 | font = QtGui.QFont()
36 | font.setPointSize(12)
37 | self.listWidgetSelectedItems.setFont(font)
38 | self.listWidgetSelectedItems.setObjectName("listWidgetSelectedItems")
39 |
40 | self.retranslateUi(Dialog)
41 | QtCore.QMetaObject.connectSlotsByName(Dialog)
42 |
43 | def retranslateUi(self, Dialog):
44 | _translate = QtCore.QCoreApplication.translate
45 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
46 | self.label.setText(_translate("Dialog", "Your favourite food item"))
47 | self.pushButtonAdd.setText(_translate("Dialog", "Add to List"))
48 |
49 |
50 | if __name__ == "__main__":
51 | import sys
52 | app = QtWidgets.QApplication(sys.argv)
53 | Dialog = QtWidgets.QDialog()
54 | ui = Ui_Dialog()
55 | ui.setupUi(Dialog)
56 | Dialog.show()
57 | sys.exit(app.exec_())
58 |
59 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidget3.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 734
10 | 270
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 20
21 | 191
22 | 16
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | Your favourite food item
32 |
33 |
34 |
35 |
36 |
37 | 210
38 | 20
39 | 201
40 | 20
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 |
50 |
51 |
52 | 110
53 | 72
54 | 111
55 | 31
56 |
57 |
58 |
59 |
60 | 12
61 |
62 |
63 |
64 | Add to List
65 |
66 |
67 |
68 |
69 |
70 | 430
71 | 20
72 | 256
73 | 221
74 |
75 |
76 |
77 |
78 | 12
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidgetOp.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoListWidgetOp.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(691, 260)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(16, 30, 121, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(12)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.lineEdit = QtWidgets.QLineEdit(Dialog)
22 | self.lineEdit.setGeometry(QtCore.QRect(130, 30, 191, 31))
23 | font = QtGui.QFont()
24 | font.setPointSize(12)
25 | self.lineEdit.setFont(font)
26 | self.lineEdit.setObjectName("lineEdit")
27 | self.pushButtonAdd = QtWidgets.QPushButton(Dialog)
28 | self.pushButtonAdd.setGeometry(QtCore.QRect(180, 80, 75, 23))
29 | font = QtGui.QFont()
30 | font.setPointSize(12)
31 | self.pushButtonAdd.setFont(font)
32 | self.pushButtonAdd.setObjectName("pushButtonAdd")
33 | self.listWidget = QtWidgets.QListWidget(Dialog)
34 | self.listWidget.setGeometry(QtCore.QRect(380, 30, 256, 192))
35 | font = QtGui.QFont()
36 | font.setPointSize(12)
37 | self.listWidget.setFont(font)
38 | self.listWidget.setObjectName("listWidget")
39 | self.pushButtonDelete = QtWidgets.QPushButton(Dialog)
40 | self.pushButtonDelete.setGeometry(QtCore.QRect(470, 230, 75, 23))
41 | font = QtGui.QFont()
42 | font.setPointSize(12)
43 | self.pushButtonDelete.setFont(font)
44 | self.pushButtonDelete.setObjectName("pushButtonDelete")
45 | self.pushButtonDeleteAll = QtWidgets.QPushButton(Dialog)
46 | self.pushButtonDeleteAll.setGeometry(QtCore.QRect(560, 230, 75, 23))
47 | font = QtGui.QFont()
48 | font.setPointSize(12)
49 | self.pushButtonDeleteAll.setFont(font)
50 | self.pushButtonDeleteAll.setObjectName("pushButtonDeleteAll")
51 | self.pushButtonEdit = QtWidgets.QPushButton(Dialog)
52 | self.pushButtonEdit.setGeometry(QtCore.QRect(380, 230, 75, 23))
53 | font = QtGui.QFont()
54 | font.setPointSize(12)
55 | self.pushButtonEdit.setFont(font)
56 | self.pushButtonEdit.setObjectName("pushButtonEdit")
57 |
58 | self.retranslateUi(Dialog)
59 | QtCore.QMetaObject.connectSlotsByName(Dialog)
60 |
61 | def retranslateUi(self, Dialog):
62 | _translate = QtCore.QCoreApplication.translate
63 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
64 | self.label.setText(_translate("Dialog", "Enter an item"))
65 | self.pushButtonAdd.setText(_translate("Dialog", "Add"))
66 | self.pushButtonDelete.setText(_translate("Dialog", "Delete"))
67 | self.pushButtonDeleteAll.setText(_translate("Dialog", "Delete All"))
68 | self.pushButtonEdit.setText(_translate("Dialog", "Edit"))
69 |
70 |
71 | if __name__ == "__main__":
72 | import sys
73 | app = QtWidgets.QApplication(sys.argv)
74 | Dialog = QtWidgets.QDialog()
75 | ui = Ui_Dialog()
76 | ui.setupUi(Dialog)
77 | Dialog.show()
78 | sys.exit(app.exec_())
79 |
80 |
--------------------------------------------------------------------------------
/Chapter02/demoListWidgetOp.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 691
10 | 260
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 16
20 | 30
21 | 121
22 | 20
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | Enter an item
32 |
33 |
34 |
35 |
36 |
37 | 130
38 | 30
39 | 191
40 | 31
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 |
50 |
51 |
52 | 180
53 | 80
54 | 75
55 | 23
56 |
57 |
58 |
59 |
60 | 12
61 |
62 |
63 |
64 | Add
65 |
66 |
67 |
68 |
69 |
70 | 380
71 | 30
72 | 256
73 | 192
74 |
75 |
76 |
77 |
78 | 12
79 |
80 |
81 |
82 |
83 |
84 |
85 | 470
86 | 230
87 | 75
88 | 23
89 |
90 |
91 |
92 |
93 | 12
94 |
95 |
96 |
97 | Delete
98 |
99 |
100 |
101 |
102 |
103 | 560
104 | 230
105 | 75
106 | 23
107 |
108 |
109 |
110 |
111 | 12
112 |
113 |
114 |
115 | Delete All
116 |
117 |
118 |
119 |
120 |
121 | 380
122 | 230
123 | 75
124 | 23
125 |
126 |
127 |
128 |
129 | 12
130 |
131 |
132 |
133 | Edit
134 |
135 |
136 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/Chapter02/demoProgressBar.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoProgressBar.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(350, 153)
15 | self.progressBar = QtWidgets.QProgressBar(Dialog)
16 | self.progressBar.setGeometry(QtCore.QRect(40, 60, 281, 23))
17 | font = QtGui.QFont()
18 | font.setPointSize(12)
19 | self.progressBar.setFont(font)
20 | self.progressBar.setProperty("value", 0)
21 | self.progressBar.setObjectName("progressBar")
22 | self.label = QtWidgets.QLabel(Dialog)
23 | self.label.setGeometry(QtCore.QRect(80, 20, 181, 21))
24 | font = QtGui.QFont()
25 | font.setPointSize(12)
26 | self.label.setFont(font)
27 | self.label.setObjectName("label")
28 | self.pushButtonStart = QtWidgets.QPushButton(Dialog)
29 | self.pushButtonStart.setGeometry(QtCore.QRect(80, 110, 151, 31))
30 | font = QtGui.QFont()
31 | font.setPointSize(12)
32 | self.pushButtonStart.setFont(font)
33 | self.pushButtonStart.setObjectName("pushButtonStart")
34 |
35 | self.retranslateUi(Dialog)
36 | QtCore.QMetaObject.connectSlotsByName(Dialog)
37 |
38 | def retranslateUi(self, Dialog):
39 | _translate = QtCore.QCoreApplication.translate
40 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
41 | self.label.setText(_translate("Dialog", "Downloading the file"))
42 | self.pushButtonStart.setText(_translate("Dialog", "Start Downloading"))
43 |
44 |
45 | if __name__ == "__main__":
46 | import sys
47 | app = QtWidgets.QApplication(sys.argv)
48 | Dialog = QtWidgets.QDialog()
49 | ui = Ui_Dialog()
50 | ui.setupUi(Dialog)
51 | Dialog.show()
52 | sys.exit(app.exec_())
53 |
54 |
--------------------------------------------------------------------------------
/Chapter02/demoProgressBar.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 350
10 | 153
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 40
20 | 60
21 | 281
22 | 23
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | 0
32 |
33 |
34 |
35 |
36 |
37 | 80
38 | 20
39 | 181
40 | 21
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 | Downloading the file
50 |
51 |
52 |
53 |
54 |
55 | 80
56 | 110
57 | 151
58 | 31
59 |
60 |
61 |
62 |
63 | 12
64 |
65 |
66 |
67 | Start Downloading
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/Chapter02/demoScrollBar.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoScrollBar.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(538, 431)
15 | self.horizontalScrollBarSugarLevel = QtWidgets.QScrollBar(Dialog)
16 | self.horizontalScrollBarSugarLevel.setGeometry(QtCore.QRect(200, 30, 301, 21))
17 | font = QtGui.QFont()
18 | font.setPointSize(12)
19 | self.horizontalScrollBarSugarLevel.setFont(font)
20 | self.horizontalScrollBarSugarLevel.setOrientation(QtCore.Qt.Horizontal)
21 | self.horizontalScrollBarSugarLevel.setObjectName("horizontalScrollBarSugarLevel")
22 | self.label = QtWidgets.QLabel(Dialog)
23 | self.label.setGeometry(QtCore.QRect(40, 30, 111, 21))
24 | font = QtGui.QFont()
25 | font.setPointSize(12)
26 | self.label.setFont(font)
27 | self.label.setObjectName("label")
28 | self.label_2 = QtWidgets.QLabel(Dialog)
29 | self.label_2.setGeometry(QtCore.QRect(40, 110, 141, 16))
30 | font = QtGui.QFont()
31 | font.setPointSize(12)
32 | self.label_2.setFont(font)
33 | self.label_2.setObjectName("label_2")
34 | self.verticalScrollBarPulseRate = QtWidgets.QScrollBar(Dialog)
35 | self.verticalScrollBarPulseRate.setGeometry(QtCore.QRect(160, 110, 16, 160))
36 | font = QtGui.QFont()
37 | font.setPointSize(12)
38 | self.verticalScrollBarPulseRate.setFont(font)
39 | self.verticalScrollBarPulseRate.setOrientation(QtCore.Qt.Vertical)
40 | self.verticalScrollBarPulseRate.setObjectName("verticalScrollBarPulseRate")
41 | self.label_3 = QtWidgets.QLabel(Dialog)
42 | self.label_3.setGeometry(QtCore.QRect(40, 70, 151, 16))
43 | font = QtGui.QFont()
44 | font.setPointSize(12)
45 | self.label_3.setFont(font)
46 | self.label_3.setObjectName("label_3")
47 | self.horizontalSliderBloodPressure = QtWidgets.QSlider(Dialog)
48 | self.horizontalSliderBloodPressure.setGeometry(QtCore.QRect(210, 70, 291, 22))
49 | font = QtGui.QFont()
50 | font.setPointSize(12)
51 | self.horizontalSliderBloodPressure.setFont(font)
52 | self.horizontalSliderBloodPressure.setOrientation(QtCore.Qt.Horizontal)
53 | self.horizontalSliderBloodPressure.setObjectName("horizontalSliderBloodPressure")
54 | self.label_4 = QtWidgets.QLabel(Dialog)
55 | self.label_4.setGeometry(QtCore.QRect(240, 110, 131, 16))
56 | font = QtGui.QFont()
57 | font.setPointSize(12)
58 | self.label_4.setFont(font)
59 | self.label_4.setObjectName("label_4")
60 | self.verticalSliderCholestrolLevel = QtWidgets.QSlider(Dialog)
61 | self.verticalSliderCholestrolLevel.setGeometry(QtCore.QRect(410, 109, 22, 171))
62 | font = QtGui.QFont()
63 | font.setPointSize(12)
64 | self.verticalSliderCholestrolLevel.setFont(font)
65 | self.verticalSliderCholestrolLevel.setOrientation(QtCore.Qt.Vertical)
66 | self.verticalSliderCholestrolLevel.setObjectName("verticalSliderCholestrolLevel")
67 | self.lineEditResult = QtWidgets.QLineEdit(Dialog)
68 | self.lineEditResult.setGeometry(QtCore.QRect(60, 340, 391, 31))
69 | font = QtGui.QFont()
70 | font.setPointSize(12)
71 | self.lineEditResult.setFont(font)
72 | self.lineEditResult.setObjectName("lineEditResult")
73 |
74 | self.retranslateUi(Dialog)
75 | QtCore.QMetaObject.connectSlotsByName(Dialog)
76 |
77 | def retranslateUi(self, Dialog):
78 | _translate = QtCore.QCoreApplication.translate
79 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
80 | self.label.setText(_translate("Dialog", "Sugar Level"))
81 | self.label_2.setText(_translate("Dialog", "Pulse rate"))
82 | self.label_3.setText(_translate("Dialog", "Blood Pressure"))
83 | self.label_4.setText(_translate("Dialog", "Cholestrol Level"))
84 |
85 |
86 | if __name__ == "__main__":
87 | import sys
88 | app = QtWidgets.QApplication(sys.argv)
89 | Dialog = QtWidgets.QDialog()
90 | ui = Ui_Dialog()
91 | ui.setupUi(Dialog)
92 | Dialog.show()
93 | sys.exit(app.exec_())
94 |
95 |
--------------------------------------------------------------------------------
/Chapter02/demoScrollBar.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 538
10 | 431
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 200
20 | 30
21 | 301
22 | 21
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | Qt::Horizontal
32 |
33 |
34 |
35 |
36 |
37 | 40
38 | 30
39 | 111
40 | 21
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 | Sugar Level
50 |
51 |
52 |
53 |
54 |
55 | 40
56 | 110
57 | 141
58 | 16
59 |
60 |
61 |
62 |
63 | 12
64 |
65 |
66 |
67 | Pulse rate
68 |
69 |
70 |
71 |
72 |
73 | 160
74 | 110
75 | 16
76 | 160
77 |
78 |
79 |
80 |
81 | 12
82 |
83 |
84 |
85 | Qt::Vertical
86 |
87 |
88 |
89 |
90 |
91 | 40
92 | 70
93 | 151
94 | 16
95 |
96 |
97 |
98 |
99 | 12
100 |
101 |
102 |
103 | Blood Pressure
104 |
105 |
106 |
107 |
108 |
109 | 210
110 | 70
111 | 291
112 | 22
113 |
114 |
115 |
116 |
117 | 12
118 |
119 |
120 |
121 | Qt::Horizontal
122 |
123 |
124 |
125 |
126 |
127 | 240
128 | 110
129 | 131
130 | 16
131 |
132 |
133 |
134 |
135 | 12
136 |
137 |
138 |
139 | Cholestrol Level
140 |
141 |
142 |
143 |
144 |
145 | 410
146 | 109
147 | 22
148 | 171
149 |
150 |
151 |
152 |
153 | 12
154 |
155 |
156 |
157 | Qt::Vertical
158 |
159 |
160 |
161 |
162 |
163 | 60
164 | 340
165 | 391
166 | 31
167 |
168 |
169 |
170 |
171 | 12
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
--------------------------------------------------------------------------------
/Chapter02/demoSignalSlot1.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoSignalSlot1.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(348, 453)
15 | self.lineEdit = QtWidgets.QLineEdit(Dialog)
16 | self.lineEdit.setGeometry(QtCore.QRect(90, 50, 181, 20))
17 | self.lineEdit.setObjectName("lineEdit")
18 | self.pushButton = QtWidgets.QPushButton(Dialog)
19 | self.pushButton.setGeometry(QtCore.QRect(140, 160, 75, 23))
20 | self.pushButton.setObjectName("pushButton")
21 | self.pushButton_2 = QtWidgets.QPushButton(Dialog)
22 | self.pushButton_2.setGeometry(QtCore.QRect(140, 260, 75, 23))
23 | self.pushButton_2.setObjectName("pushButton_2")
24 | self.lineEdit_2 = QtWidgets.QLineEdit(Dialog)
25 | self.lineEdit_2.setGeometry(QtCore.QRect(90, 390, 181, 20))
26 | self.lineEdit_2.setObjectName("lineEdit_2")
27 |
28 | self.retranslateUi(Dialog)
29 | self.pushButton.pressed.connect(self.lineEdit.selectAll)
30 | self.pushButton_2.clicked.connect(self.lineEdit_2.paste)
31 | self.pushButton.released.connect(self.lineEdit.copy)
32 | QtCore.QMetaObject.connectSlotsByName(Dialog)
33 |
34 | def retranslateUi(self, Dialog):
35 | _translate = QtCore.QCoreApplication.translate
36 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
37 | self.pushButton.setText(_translate("Dialog", "Copy"))
38 | self.pushButton_2.setText(_translate("Dialog", "Paste"))
39 |
40 |
41 | if __name__ == "__main__":
42 | import sys
43 | app = QtWidgets.QApplication(sys.argv)
44 | Dialog = QtWidgets.QDialog()
45 | ui = Ui_Dialog()
46 | ui.setupUi(Dialog)
47 | Dialog.show()
48 | sys.exit(app.exec_())
49 |
50 |
--------------------------------------------------------------------------------
/Chapter02/demoSignalSlot1.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 348
10 | 453
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 90
20 | 50
21 | 181
22 | 20
23 |
24 |
25 |
26 |
27 |
28 |
29 | 140
30 | 160
31 | 75
32 | 23
33 |
34 |
35 |
36 | Copy
37 |
38 |
39 |
40 |
41 |
42 | 140
43 | 260
44 | 75
45 | 23
46 |
47 |
48 |
49 | Paste
50 |
51 |
52 |
53 |
54 |
55 | 90
56 | 390
57 | 181
58 | 20
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | pushButton
67 | pressed()
68 | lineEdit
69 | selectAll()
70 |
71 |
72 | 175
73 | 181
74 |
75 |
76 | 183
77 | 67
78 |
79 |
80 |
81 |
82 | pushButton_2
83 | clicked()
84 | lineEdit_2
85 | paste()
86 |
87 |
88 | 174
89 | 277
90 |
91 |
92 | 172
93 | 396
94 |
95 |
96 |
97 |
98 | pushButton
99 | released()
100 | lineEdit
101 | copy()
102 |
103 |
104 | 150
105 | 169
106 |
107 |
108 | 153
109 | 58
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/Chapter02/demoSpinBox.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoSpinBox.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(580, 162)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(16, 30, 81, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(12)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.lineEditBookPrice = QtWidgets.QLineEdit(Dialog)
22 | self.lineEditBookPrice.setGeometry(QtCore.QRect(120, 30, 113, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(12)
25 | self.lineEditBookPrice.setFont(font)
26 | self.lineEditBookPrice.setObjectName("lineEditBookPrice")
27 | self.spinBoxBookQty = QtWidgets.QSpinBox(Dialog)
28 | self.spinBoxBookQty.setGeometry(QtCore.QRect(290, 30, 42, 22))
29 | font = QtGui.QFont()
30 | font.setPointSize(12)
31 | self.spinBoxBookQty.setFont(font)
32 | self.spinBoxBookQty.setObjectName("spinBoxBookQty")
33 | self.lineEditBookAmount = QtWidgets.QLineEdit(Dialog)
34 | self.lineEditBookAmount.setGeometry(QtCore.QRect(390, 30, 113, 20))
35 | font = QtGui.QFont()
36 | font.setPointSize(12)
37 | self.lineEditBookAmount.setFont(font)
38 | self.lineEditBookAmount.setObjectName("lineEditBookAmount")
39 | self.label_2 = QtWidgets.QLabel(Dialog)
40 | self.label_2.setGeometry(QtCore.QRect(10, 70, 81, 21))
41 | font = QtGui.QFont()
42 | font.setPointSize(12)
43 | self.label_2.setFont(font)
44 | self.label_2.setObjectName("label_2")
45 | self.lineEditSugarPrice = QtWidgets.QLineEdit(Dialog)
46 | self.lineEditSugarPrice.setGeometry(QtCore.QRect(120, 70, 113, 20))
47 | font = QtGui.QFont()
48 | font.setPointSize(12)
49 | self.lineEditSugarPrice.setFont(font)
50 | self.lineEditSugarPrice.setObjectName("lineEditSugarPrice")
51 | self.doubleSpinBoxSugarWeight = QtWidgets.QDoubleSpinBox(Dialog)
52 | self.doubleSpinBoxSugarWeight.setGeometry(QtCore.QRect(290, 70, 62, 22))
53 | font = QtGui.QFont()
54 | font.setPointSize(12)
55 | self.doubleSpinBoxSugarWeight.setFont(font)
56 | self.doubleSpinBoxSugarWeight.setObjectName("doubleSpinBoxSugarWeight")
57 | self.lineEditSugarAmount = QtWidgets.QLineEdit(Dialog)
58 | self.lineEditSugarAmount.setGeometry(QtCore.QRect(390, 70, 113, 20))
59 | font = QtGui.QFont()
60 | font.setPointSize(12)
61 | self.lineEditSugarAmount.setFont(font)
62 | self.lineEditSugarAmount.setObjectName("lineEditSugarAmount")
63 | self.labelTotalAmount = QtWidgets.QLabel(Dialog)
64 | self.labelTotalAmount.setGeometry(QtCore.QRect(396, 120, 121, 20))
65 | font = QtGui.QFont()
66 | font.setPointSize(12)
67 | self.labelTotalAmount.setFont(font)
68 | self.labelTotalAmount.setObjectName("labelTotalAmount")
69 |
70 | self.retranslateUi(Dialog)
71 | QtCore.QMetaObject.connectSlotsByName(Dialog)
72 |
73 | def retranslateUi(self, Dialog):
74 | _translate = QtCore.QCoreApplication.translate
75 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
76 | self.label.setText(_translate("Dialog", "Book Price"))
77 | self.label_2.setText(_translate("Dialog", "Sugar Price"))
78 | self.labelTotalAmount.setText(_translate("Dialog", "TextLabel"))
79 |
80 |
--------------------------------------------------------------------------------
/Chapter02/demoSpinBox.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 580
10 | 162
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 16
20 | 30
21 | 81
22 | 20
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | Book Price
32 |
33 |
34 |
35 |
36 |
37 | 120
38 | 30
39 | 113
40 | 20
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 |
50 |
51 |
52 | 290
53 | 30
54 | 42
55 | 22
56 |
57 |
58 |
59 |
60 | 12
61 |
62 |
63 |
64 |
65 |
66 |
67 | 390
68 | 30
69 | 113
70 | 20
71 |
72 |
73 |
74 |
75 | 12
76 |
77 |
78 |
79 |
80 |
81 |
82 | 10
83 | 70
84 | 81
85 | 21
86 |
87 |
88 |
89 |
90 | 12
91 |
92 |
93 |
94 | Sugar Price
95 |
96 |
97 |
98 |
99 |
100 | 120
101 | 70
102 | 113
103 | 20
104 |
105 |
106 |
107 |
108 | 12
109 |
110 |
111 |
112 |
113 |
114 |
115 | 290
116 | 70
117 | 62
118 | 22
119 |
120 |
121 |
122 |
123 | 12
124 |
125 |
126 |
127 |
128 |
129 |
130 | 390
131 | 70
132 | 113
133 | 20
134 |
135 |
136 |
137 |
138 | 12
139 |
140 |
141 |
142 |
143 |
144 |
145 | 396
146 | 120
147 | 121
148 | 20
149 |
150 |
151 |
152 |
153 | 12
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/Chapter03/DemoTableWidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 289
10 | 236
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 30
20 | 20
21 | 221
22 | 191
23 |
24 |
25 |
26 | 4
27 |
28 |
29 | 2
30 |
31 |
32 | 50
33 |
34 |
35 | false
36 |
37 |
38 | 40
39 |
40 |
41 | false
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/Chapter03/callCalendar.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoCalendar import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.calendarWidget.selectionChanged.connect(self.dispdate)
13 | self.show()
14 |
15 | def dispdate(self):
16 | self.ui.dateEdit.setDisplayFormat('MMM d yyyy')
17 | self.ui.dateEdit.setDate(self.ui.calendarWidget.selectedDate())
18 |
19 |
20 | if __name__=="__main__":
21 | app = QApplication(sys.argv)
22 | w = MyForm()
23 | w.show()
24 | sys.exit(app.exec_())
25 |
--------------------------------------------------------------------------------
/Chapter03/callLCD.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoLCD import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | timer = QtCore.QTimer(self)
13 | timer.timeout.connect(self.showlcd)
14 | timer.start(1000)
15 | self.showlcd()
16 |
17 | def showlcd(self):
18 | time = QtCore.QTime.currentTime()
19 | text = time.toString('hh:mm')
20 | self.ui.lcdNumber.display(text)
21 |
22 | if __name__=="__main__":
23 | app = QApplication(sys.argv)
24 | w = MyForm()
25 | w.show()
26 | sys.exit(app.exec_())
27 |
--------------------------------------------------------------------------------
/Chapter03/callTableWidget.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication,QTableWidgetItem
4 | from DemoTableWidget import *
5 |
6 | class MyForm(QDialog):
7 | def __init__(self,data):
8 | super().__init__()
9 | self.ui = Ui_Dialog()
10 | self.ui.setupUi(self)
11 | self.data=data
12 | self.addcontent()
13 |
14 | def addcontent(self):
15 | row=0
16 | for tup in self.data:
17 | col=0
18 | for item in tup:
19 | oneitem=QTableWidgetItem(item)
20 | self.ui.tableWidget.setItem(row, col, oneitem)
21 | col+=1
22 | row+=1
23 | data=[]
24 | data.append(('Suite', '40$'))
25 | data.append(('Super Luxury', '30$'))
26 | data.append(('Super Deluxe', '20$'))
27 | data.append(('Ordinary', '10$'))
28 |
29 |
30 | if __name__=="__main__":
31 | app = QApplication(sys.argv)
32 | w = MyForm(data)
33 | w.show()
34 | sys.exit(app.exec_())
35 |
--------------------------------------------------------------------------------
/Chapter03/computeRoomRent.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from reservehotel import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.roomtypes=['Suite', 'Super Luxury', 'Super Deluxe', 'Ordinary']
13 | self.addcontent()
14 | self.ui.pushButton.clicked.connect(self.computeRoomRent)
15 | self.show()
16 |
17 | def addcontent(self):
18 | for i in self.roomtypes:
19 | self.ui.comboBox.addItem(i)
20 |
21 | def computeRoomRent(self):
22 | dateselected=self.ui.calendarWidget.selectedDate()
23 | dateinstring=str(dateselected.toPyDate())
24 | noOfDays=self.ui.spinBox.value()
25 | chosenRoomType=self.ui.comboBox.itemText(self.ui.comboBox.currentIndex())
26 | self.ui.Enteredinfo.setText('Date of reservation: '+dateinstring+ ', Number of days: '+ str(noOfDays) + ' \nand Room type selected: '+ chosenRoomType)
27 | roomRent=0
28 | if chosenRoomType=="Suite":
29 | roomRent=40
30 | if chosenRoomType=="Super Luxury":
31 | roomRent=30
32 | if chosenRoomType=="Super Deluxe":
33 | roomRent=20
34 | if chosenRoomType=="Ordinary":
35 | roomRent=10
36 | total=roomRent*noOfDays
37 | self.ui.RoomRentinfo.setText('Room Rent for single day for '+ chosenRoomType +' type is '+ str(roomRent)+ '$. \nTotal room rent is '+ str(total)+ '$')
38 |
39 | if __name__=="__main__":
40 | app = QApplication(sys.argv)
41 | w = MyForm()
42 | w.show()
43 | sys.exit(app.exec_())
44 |
--------------------------------------------------------------------------------
/Chapter03/demoCalendar.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoCalendar.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(384, 300)
15 | self.calendarWidget = QtWidgets.QCalendarWidget(Dialog)
16 | self.calendarWidget.setGeometry(QtCore.QRect(40, 30, 312, 183))
17 | self.calendarWidget.setObjectName("calendarWidget")
18 | self.dateEdit = QtWidgets.QDateEdit(Dialog)
19 | self.dateEdit.setGeometry(QtCore.QRect(120, 250, 110, 22))
20 | self.dateEdit.setObjectName("dateEdit")
21 |
22 | self.retranslateUi(Dialog)
23 | QtCore.QMetaObject.connectSlotsByName(Dialog)
24 |
25 | def retranslateUi(self, Dialog):
26 | _translate = QtCore.QCoreApplication.translate
27 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
28 |
29 |
30 | if __name__ == "__main__":
31 | import sys
32 | app = QtWidgets.QApplication(sys.argv)
33 | Dialog = QtWidgets.QDialog()
34 | ui = Ui_Dialog()
35 | ui.setupUi(Dialog)
36 | Dialog.show()
37 | sys.exit(app.exec_())
38 |
39 |
--------------------------------------------------------------------------------
/Chapter03/demoCalendar.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 384
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 40
20 | 30
21 | 312
22 | 183
23 |
24 |
25 |
26 |
27 |
28 |
29 | 120
30 | 250
31 | 110
32 | 22
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Chapter03/demoLCD.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoLCD.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(240, 135)
15 | self.lcdNumber = QtWidgets.QLCDNumber(Dialog)
16 | self.lcdNumber.setGeometry(QtCore.QRect(60, 40, 100, 40))
17 | self.lcdNumber.setObjectName("lcdNumber")
18 |
19 | self.retranslateUi(Dialog)
20 | QtCore.QMetaObject.connectSlotsByName(Dialog)
21 |
22 | def retranslateUi(self, Dialog):
23 | _translate = QtCore.QCoreApplication.translate
24 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
25 |
26 |
27 | if __name__ == "__main__":
28 | import sys
29 | app = QtWidgets.QApplication(sys.argv)
30 | Dialog = QtWidgets.QDialog()
31 | ui = Ui_Dialog()
32 | ui.setupUi(Dialog)
33 | Dialog.show()
34 | sys.exit(app.exec_())
35 |
36 |
--------------------------------------------------------------------------------
/Chapter03/demoLCD.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 240
10 | 135
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 60
20 | 40
21 | 100
22 | 40
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Chapter03/reservehotel.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'reservehotel.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(553, 556)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(140, 10, 241, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(17)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.label_2 = QtWidgets.QLabel(Dialog)
22 | self.label_2.setGeometry(QtCore.QRect(10, 60, 161, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(12)
25 | self.label_2.setFont(font)
26 | self.label_2.setObjectName("label_2")
27 | self.label_3 = QtWidgets.QLabel(Dialog)
28 | self.label_3.setGeometry(QtCore.QRect(10, 250, 161, 31))
29 | font = QtGui.QFont()
30 | font.setPointSize(12)
31 | self.label_3.setFont(font)
32 | self.label_3.setObjectName("label_3")
33 | self.calendarWidget = QtWidgets.QCalendarWidget(Dialog)
34 | self.calendarWidget.setGeometry(QtCore.QRect(210, 60, 312, 183))
35 | font = QtGui.QFont()
36 | font.setPointSize(12)
37 | self.calendarWidget.setFont(font)
38 | self.calendarWidget.setObjectName("calendarWidget")
39 | self.spinBox = QtWidgets.QSpinBox(Dialog)
40 | self.spinBox.setGeometry(QtCore.QRect(210, 260, 42, 22))
41 | font = QtGui.QFont()
42 | font.setPointSize(12)
43 | self.spinBox.setFont(font)
44 | self.spinBox.setObjectName("spinBox")
45 | self.label_4 = QtWidgets.QLabel(Dialog)
46 | self.label_4.setGeometry(QtCore.QRect(20, 300, 111, 20))
47 | font = QtGui.QFont()
48 | font.setPointSize(12)
49 | self.label_4.setFont(font)
50 | self.label_4.setObjectName("label_4")
51 | self.comboBox = QtWidgets.QComboBox(Dialog)
52 | self.comboBox.setGeometry(QtCore.QRect(210, 300, 211, 22))
53 | font = QtGui.QFont()
54 | font.setPointSize(12)
55 | self.comboBox.setFont(font)
56 | self.comboBox.setObjectName("comboBox")
57 | self.pushButton = QtWidgets.QPushButton(Dialog)
58 | self.pushButton.setGeometry(QtCore.QRect(170, 350, 241, 31))
59 | font = QtGui.QFont()
60 | font.setPointSize(12)
61 | self.pushButton.setFont(font)
62 | self.pushButton.setObjectName("pushButton")
63 | self.Enteredinfo = QtWidgets.QLabel(Dialog)
64 | self.Enteredinfo.setGeometry(QtCore.QRect(20, 400, 501, 51))
65 | font = QtGui.QFont()
66 | font.setPointSize(12)
67 | self.Enteredinfo.setFont(font)
68 | self.Enteredinfo.setText("")
69 | self.Enteredinfo.setObjectName("Enteredinfo")
70 | self.RoomRentinfo = QtWidgets.QLabel(Dialog)
71 | self.RoomRentinfo.setGeometry(QtCore.QRect(10, 480, 501, 51))
72 | font = QtGui.QFont()
73 | font.setPointSize(12)
74 | self.RoomRentinfo.setFont(font)
75 | self.RoomRentinfo.setText("")
76 | self.RoomRentinfo.setObjectName("RoomRentinfo")
77 |
78 | self.retranslateUi(Dialog)
79 | QtCore.QMetaObject.connectSlotsByName(Dialog)
80 |
81 | def retranslateUi(self, Dialog):
82 | _translate = QtCore.QCoreApplication.translate
83 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
84 | self.label.setText(_translate("Dialog", "Hotel Room Reservation"))
85 | self.label_2.setText(_translate("Dialog", "Date of Reservation"))
86 | self.label_3.setText(_translate("Dialog", "Number of days"))
87 | self.label_4.setText(_translate("Dialog", "Room type"))
88 | self.pushButton.setText(_translate("Dialog", "Caclulate Room Rent"))
89 |
90 |
--------------------------------------------------------------------------------
/Chapter03/reservehotel.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 553
10 | 556
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 140
20 | 10
21 | 241
22 | 20
23 |
24 |
25 |
26 |
27 | 17
28 |
29 |
30 |
31 | Hotel Room Reservation
32 |
33 |
34 |
35 |
36 |
37 | 10
38 | 60
39 | 161
40 | 20
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 | Date of Reservation
50 |
51 |
52 |
53 |
54 |
55 | 10
56 | 250
57 | 161
58 | 31
59 |
60 |
61 |
62 |
63 | 12
64 |
65 |
66 |
67 | Number of days
68 |
69 |
70 |
71 |
72 |
73 | 210
74 | 60
75 | 312
76 | 183
77 |
78 |
79 |
80 |
81 | 12
82 |
83 |
84 |
85 |
86 |
87 |
88 | 210
89 | 260
90 | 42
91 | 22
92 |
93 |
94 |
95 |
96 | 12
97 |
98 |
99 |
100 |
101 |
102 |
103 | 20
104 | 300
105 | 111
106 | 20
107 |
108 |
109 |
110 |
111 | 12
112 |
113 |
114 |
115 | Room type
116 |
117 |
118 |
119 |
120 |
121 | 210
122 | 300
123 | 211
124 | 22
125 |
126 |
127 |
128 |
129 | 12
130 |
131 |
132 |
133 |
134 |
135 |
136 | 170
137 | 350
138 | 241
139 | 31
140 |
141 |
142 |
143 |
144 | 12
145 |
146 |
147 |
148 | Caclulate Room Rent
149 |
150 |
151 |
152 |
153 |
154 | 20
155 | 400
156 | 501
157 | 51
158 |
159 |
160 |
161 |
162 | 12
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 | 10
173 | 480
174 | 501
175 | 51
176 |
177 |
178 |
179 |
180 | 12
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------
/Chapter04/LineEditClass.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoLineEdit.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(379, 195)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(6, 40, 121, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(11)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.labelResponse = QtWidgets.QLabel(Dialog)
22 | self.labelResponse.setGeometry(QtCore.QRect(40, 90, 271, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(11)
25 | self.labelResponse.setFont(font)
26 | self.labelResponse.setObjectName("labelResponse")
27 | self.lineEditName = QtWidgets.QLineEdit(Dialog)
28 | self.lineEditName.setGeometry(QtCore.QRect(140, 40, 201, 20))
29 | font = QtGui.QFont()
30 | font.setPointSize(11)
31 | self.lineEditName.setFont(font)
32 | self.lineEditName.setObjectName("lineEditName")
33 | self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
34 | self.ButtonClickMe.setGeometry(QtCore.QRect(160, 130, 101, 23))
35 | font = QtGui.QFont()
36 | font.setPointSize(11)
37 | self.ButtonClickMe.setFont(font)
38 | self.ButtonClickMe.setObjectName("ButtonClickMe")
39 |
40 | self.retranslateUi(Dialog)
41 | QtCore.QMetaObject.connectSlotsByName(Dialog)
42 |
43 | def retranslateUi(self, Dialog):
44 | _translate = QtCore.QCoreApplication.translate
45 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
46 | self.label.setText(_translate("Dialog", "Enter your name"))
47 | self.labelResponse.setText(_translate("Dialog", "TextLabel"))
48 | self.ButtonClickMe.setText(_translate("Dialog", "Click"))
49 |
50 |
--------------------------------------------------------------------------------
/Chapter04/LineEditClass.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 379
10 | 195
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 6
20 | 40
21 | 121
22 | 20
23 |
24 |
25 |
26 |
27 | 11
28 |
29 |
30 |
31 | Enter your name
32 |
33 |
34 |
35 |
36 |
37 | 40
38 | 90
39 | 271
40 | 20
41 |
42 |
43 |
44 |
45 | 11
46 |
47 |
48 |
49 | TextLabel
50 |
51 |
52 |
53 |
54 |
55 | 140
56 | 40
57 | 201
58 | 20
59 |
60 |
61 |
62 |
63 | 11
64 |
65 |
66 |
67 |
68 |
69 |
70 | 160
71 | 130
72 | 101
73 | 23
74 |
75 |
76 |
77 |
78 | 11
79 |
80 |
81 |
82 | Click
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Chapter04/callLineEditClass.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from LineEditClass import *
6 |
7 | class Student:
8 | name = ""
9 |
10 | def __init__(self, name):
11 | self.name = name
12 |
13 | def printName(self):
14 | return self.name
15 |
16 | class MyForm(QDialog):
17 | def __init__(self):
18 | super().__init__()
19 | self.ui = Ui_Dialog()
20 | self.ui.setupUi(self)
21 | self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
22 | self.show()
23 |
24 | def dispmessage(self):
25 | studentObj=Student(self.ui.lineEditName.text())
26 | self.ui.labelResponse.setText("Hello "+studentObj.printName())
27 |
28 | if __name__=="__main__":
29 | app = QApplication(sys.argv)
30 | w = MyForm()
31 | w.show()
32 | sys.exit(app.exec_())
33 |
--------------------------------------------------------------------------------
/Chapter04/callMultilevelInheritance.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoMultilevelInheritance import *
6 |
7 | class Student:
8 | name = ""
9 | code = ""
10 |
11 | def __init__(self, code, name):
12 | self.code = code
13 | self.name = name
14 |
15 | def getCode(self):
16 | return self.code
17 |
18 | def getName(self):
19 | return self.name
20 |
21 |
22 | class Marks(Student):
23 | historyMarks = 0
24 | geographyMarks = 0
25 |
26 | def __init__(self, code, name, historyMarks, geographyMarks):
27 | Student.__init__(self,code,name)
28 | self.historyMarks = historyMarks
29 | self.geographyMarks = geographyMarks
30 |
31 | def getHistoryMarks(self):
32 | return self.historyMarks
33 |
34 | def getGeographyMarks(self):
35 | return self.geographyMarks
36 |
37 | class Result(Marks):
38 | totalMarks = 0
39 | percentage = 0
40 |
41 | def __init__(self, code, name, historyMarks, geographyMarks):
42 | Marks.__init__(self, code, name, historyMarks, geographyMarks)
43 | self.totalMarks = historyMarks + geographyMarks
44 | self.percentage = (historyMarks + geographyMarks) / 200 * 100
45 |
46 | def getTotalMarks(self):
47 | return self.totalMarks
48 |
49 | def getPercentage(self):
50 | return self.percentage
51 |
52 | class MyForm(QDialog):
53 | def __init__(self):
54 | super().__init__()
55 | self.ui = Ui_Dialog()
56 | self.ui.setupUi(self)
57 | self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
58 | self.show()
59 |
60 | def dispmessage(self):
61 | resultObj=Result(self.ui.lineEditCode.text(), self.ui.lineEditName.text(), int(self.ui.lineEditHistoryMarks.text()), int(self.ui.lineEditGeographyMarks.text()))
62 | self.ui.lineEditTotal.setText(str(resultObj.getTotalMarks()))
63 | self.ui.lineEditPercentage.setText(str(resultObj.getPercentage()))
64 |
65 | if __name__=="__main__":
66 | app = QApplication(sys.argv)
67 | w = MyForm()
68 | w.show()
69 | sys.exit(app.exec_())
70 |
--------------------------------------------------------------------------------
/Chapter04/callMultipleInheritance.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoMultipleInheritance import *
6 |
7 | class Student:
8 | name = ""
9 | code = ""
10 |
11 | def __init__(self, code, name):
12 | self.code = code
13 | self.name = name
14 |
15 | def getCode(self):
16 | return self.code
17 |
18 | def getName(self):
19 | return self.name
20 |
21 |
22 | class Marks:
23 | historyMarks = 0
24 | geographyMarks = 0
25 |
26 | def __init__(self, historyMarks, geographyMarks):
27 | self.historyMarks = historyMarks
28 | self.geographyMarks = geographyMarks
29 |
30 | def getHistoryMarks(self):
31 | return self.historyMarks
32 |
33 | def getGeographyMarks(self):
34 | return self.geographyMarks
35 |
36 | class Result(Student, Marks):
37 | totalMarks = 0
38 | percentage = 0
39 |
40 | def __init__(self, code, name, historyMarks, geographyMarks):
41 | Student.__init__(self, code, name)
42 | Marks.__init__(self, historyMarks, geographyMarks)
43 | self.totalMarks = historyMarks + geographyMarks
44 | self.percentage = (historyMarks + geographyMarks) / 200 * 100
45 |
46 | def getTotalMarks(self):
47 | return self.totalMarks
48 |
49 | def getPercentage(self):
50 | return self.percentage
51 |
52 | class MyForm(QDialog):
53 | def __init__(self):
54 | super().__init__()
55 | self.ui = Ui_Dialog()
56 | self.ui.setupUi(self)
57 | self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
58 | self.show()
59 |
60 | def dispmessage(self):
61 | resultObj=Result(self.ui.lineEditCode.text(), self.ui.lineEditName.text(), int(self.ui.lineEditHistoryMarks.text()), int(self.ui.lineEditGeographyMarks.text()))
62 | self.ui.lineEditTotal.setText(str(resultObj.getTotalMarks()))
63 | self.ui.lineEditPercentage.setText(str(resultObj.getPercentage()))
64 |
65 | if __name__=="__main__":
66 | app = QApplication(sys.argv)
67 | w = MyForm()
68 | w.show()
69 | sys.exit(app.exec_())
70 |
--------------------------------------------------------------------------------
/Chapter04/callSimpleInheritance.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoSimpleInheritance import *
6 |
7 | class Student:
8 | name = ""
9 | code = ""
10 |
11 | def __init__(self, code, name):
12 | self.code = code
13 | self.name = name
14 |
15 | def getCode(self):
16 | return self.code
17 |
18 | def getName(self):
19 | return self.name
20 |
21 |
22 | class Marks(Student):
23 | historyMarks = 0
24 | geographyMarks = 0
25 |
26 | def __init__(self, code, name, historyMarks, geographyMarks):
27 | Student.__init__(self,code,name)
28 | self.historyMarks = historyMarks
29 | self.geographyMarks = geographyMarks
30 |
31 | def getHistoryMarks(self):
32 | return self.historyMarks
33 |
34 | def getGeographyMarks(self):
35 | return self.geographyMarks
36 |
37 |
38 | class MyForm(QDialog):
39 | def __init__(self):
40 | super().__init__()
41 | self.ui = Ui_Dialog()
42 | self.ui.setupUi(self)
43 | self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
44 | self.show()
45 |
46 | def dispmessage(self):
47 | marksObj=Marks(self.ui.lineEditCode.text(), self.ui.lineEditName.text(), self.ui.lineEditHistoryMarks.text(), self.ui.lineEditGeographyMarks.text())
48 | self.ui.labelResponse.setText("Code: "+marksObj.getCode()+", Name:"+marksObj.getName()+"\nHistory Marks:"+marksObj.getHistoryMarks()+", Geography Marks:"+marksObj.getGeographyMarks())
49 |
50 | if __name__=="__main__":
51 | app = QApplication(sys.argv)
52 | w = MyForm()
53 | w.show()
54 | sys.exit(app.exec_())
55 |
--------------------------------------------------------------------------------
/Chapter04/callStudentClass.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication
4 |
5 | from demoStudentClass import *
6 |
7 | class Student:
8 | name = ""
9 | code = ""
10 |
11 | def __init__(self, code, name):
12 | self.code = code
13 | self.name = name
14 |
15 | def getCode(self):
16 | return self.code
17 |
18 | def getName(self):
19 | return self.name
20 |
21 | class MyForm(QDialog):
22 | def __init__(self):
23 | super().__init__()
24 | self.ui = Ui_Dialog()
25 | self.ui.setupUi(self)
26 | self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
27 | self.show()
28 |
29 | def dispmessage(self):
30 | studentObj=Student(self.ui.lineEditCode.text(), self.ui.lineEditName.text())
31 | self.ui.labelResponse.setText("Code: "+studentObj.getCode()+", Name:"+studentObj.getName())
32 |
33 | if __name__=="__main__":
34 | app = QApplication(sys.argv)
35 | w = MyForm()
36 | w.show()
37 | sys.exit(app.exec_())
38 |
--------------------------------------------------------------------------------
/Chapter04/demoMultilevelInheritance.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoMultilevelInheritance.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(382, 322)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(11)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.lineEditName = QtWidgets.QLineEdit(Dialog)
22 | self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(11)
25 | self.lineEditName.setFont(font)
26 | self.lineEditName.setObjectName("lineEditName")
27 | self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
28 | self.ButtonClickMe.setGeometry(QtCore.QRect(150, 280, 101, 23))
29 | font = QtGui.QFont()
30 | font.setPointSize(11)
31 | self.ButtonClickMe.setFont(font)
32 | self.ButtonClickMe.setObjectName("ButtonClickMe")
33 | self.lineEditCode = QtWidgets.QLineEdit(Dialog)
34 | self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
35 | font = QtGui.QFont()
36 | font.setPointSize(11)
37 | self.lineEditCode.setFont(font)
38 | self.lineEditCode.setObjectName("lineEditCode")
39 | self.label_2 = QtWidgets.QLabel(Dialog)
40 | self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
41 | font = QtGui.QFont()
42 | font.setPointSize(11)
43 | self.label_2.setFont(font)
44 | self.label_2.setObjectName("label_2")
45 | self.lineEditHistoryMarks = QtWidgets.QLineEdit(Dialog)
46 | self.lineEditHistoryMarks.setGeometry(QtCore.QRect(140, 100, 201, 20))
47 | font = QtGui.QFont()
48 | font.setPointSize(11)
49 | self.lineEditHistoryMarks.setFont(font)
50 | self.lineEditHistoryMarks.setObjectName("lineEditHistoryMarks")
51 | self.label_3 = QtWidgets.QLabel(Dialog)
52 | self.label_3.setGeometry(QtCore.QRect(20, 100, 121, 20))
53 | font = QtGui.QFont()
54 | font.setPointSize(11)
55 | self.label_3.setFont(font)
56 | self.label_3.setObjectName("label_3")
57 | self.label_4 = QtWidgets.QLabel(Dialog)
58 | self.label_4.setGeometry(QtCore.QRect(20, 140, 121, 20))
59 | font = QtGui.QFont()
60 | font.setPointSize(11)
61 | self.label_4.setFont(font)
62 | self.label_4.setObjectName("label_4")
63 | self.lineEditGeographyMarks = QtWidgets.QLineEdit(Dialog)
64 | self.lineEditGeographyMarks.setGeometry(QtCore.QRect(140, 140, 201, 20))
65 | font = QtGui.QFont()
66 | font.setPointSize(11)
67 | self.lineEditGeographyMarks.setFont(font)
68 | self.lineEditGeographyMarks.setObjectName("lineEditGeographyMarks")
69 | self.lineEditPercentage = QtWidgets.QLineEdit(Dialog)
70 | self.lineEditPercentage.setEnabled(False)
71 | self.lineEditPercentage.setGeometry(QtCore.QRect(140, 220, 201, 20))
72 | font = QtGui.QFont()
73 | font.setPointSize(11)
74 | self.lineEditPercentage.setFont(font)
75 | self.lineEditPercentage.setObjectName("lineEditPercentage")
76 | self.label_5 = QtWidgets.QLabel(Dialog)
77 | self.label_5.setGeometry(QtCore.QRect(20, 220, 121, 20))
78 | font = QtGui.QFont()
79 | font.setPointSize(11)
80 | self.label_5.setFont(font)
81 | self.label_5.setObjectName("label_5")
82 | self.lineEditTotal = QtWidgets.QLineEdit(Dialog)
83 | self.lineEditTotal.setEnabled(False)
84 | self.lineEditTotal.setGeometry(QtCore.QRect(140, 180, 201, 20))
85 | font = QtGui.QFont()
86 | font.setPointSize(11)
87 | self.lineEditTotal.setFont(font)
88 | self.lineEditTotal.setObjectName("lineEditTotal")
89 | self.label_6 = QtWidgets.QLabel(Dialog)
90 | self.label_6.setGeometry(QtCore.QRect(20, 180, 121, 20))
91 | font = QtGui.QFont()
92 | font.setPointSize(11)
93 | self.label_6.setFont(font)
94 | self.label_6.setObjectName("label_6")
95 |
96 | self.retranslateUi(Dialog)
97 | QtCore.QMetaObject.connectSlotsByName(Dialog)
98 |
99 | def retranslateUi(self, Dialog):
100 | _translate = QtCore.QCoreApplication.translate
101 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
102 | self.label.setText(_translate("Dialog", "Student Name"))
103 | self.ButtonClickMe.setText(_translate("Dialog", "Click"))
104 | self.label_2.setText(_translate("Dialog", "Student Code"))
105 | self.label_3.setText(_translate("Dialog", "History Marks"))
106 | self.label_4.setText(_translate("Dialog", "Geography Marks"))
107 | self.label_5.setText(_translate("Dialog", "Percentage"))
108 | self.label_6.setText(_translate("Dialog", "Total"))
109 |
110 |
111 | if __name__ == "__main__":
112 | import sys
113 | app = QtWidgets.QApplication(sys.argv)
114 | Dialog = QtWidgets.QDialog()
115 | ui = Ui_Dialog()
116 | ui.setupUi(Dialog)
117 | Dialog.show()
118 | sys.exit(app.exec_())
119 |
120 |
--------------------------------------------------------------------------------
/Chapter04/demoMultilevelInheritance.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 382
10 | 322
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 60
21 | 121
22 | 20
23 |
24 |
25 |
26 |
27 | 11
28 |
29 |
30 |
31 | Student Name
32 |
33 |
34 |
35 |
36 |
37 | 140
38 | 60
39 | 201
40 | 20
41 |
42 |
43 |
44 |
45 | 11
46 |
47 |
48 |
49 |
50 |
51 |
52 | 150
53 | 280
54 | 101
55 | 23
56 |
57 |
58 |
59 |
60 | 11
61 |
62 |
63 |
64 | Click
65 |
66 |
67 |
68 |
69 |
70 | 140
71 | 20
72 | 201
73 | 20
74 |
75 |
76 |
77 |
78 | 11
79 |
80 |
81 |
82 |
83 |
84 |
85 | 20
86 | 20
87 | 121
88 | 20
89 |
90 |
91 |
92 |
93 | 11
94 |
95 |
96 |
97 | Student Code
98 |
99 |
100 |
101 |
102 |
103 | 140
104 | 100
105 | 201
106 | 20
107 |
108 |
109 |
110 |
111 | 11
112 |
113 |
114 |
115 |
116 |
117 |
118 | 20
119 | 100
120 | 121
121 | 20
122 |
123 |
124 |
125 |
126 | 11
127 |
128 |
129 |
130 | History Marks
131 |
132 |
133 |
134 |
135 |
136 | 20
137 | 140
138 | 121
139 | 20
140 |
141 |
142 |
143 |
144 | 11
145 |
146 |
147 |
148 | Geography Marks
149 |
150 |
151 |
152 |
153 |
154 | 140
155 | 140
156 | 201
157 | 20
158 |
159 |
160 |
161 |
162 | 11
163 |
164 |
165 |
166 |
167 |
168 | false
169 |
170 |
171 |
172 | 140
173 | 220
174 | 201
175 | 20
176 |
177 |
178 |
179 |
180 | 11
181 |
182 |
183 |
184 |
185 |
186 |
187 | 20
188 | 220
189 | 121
190 | 20
191 |
192 |
193 |
194 |
195 | 11
196 |
197 |
198 |
199 | Percentage
200 |
201 |
202 |
203 |
204 | false
205 |
206 |
207 |
208 | 140
209 | 180
210 | 201
211 | 20
212 |
213 |
214 |
215 |
216 | 11
217 |
218 |
219 |
220 |
221 |
222 |
223 | 20
224 | 180
225 | 121
226 | 20
227 |
228 |
229 |
230 |
231 | 11
232 |
233 |
234 |
235 | Total
236 |
237 |
238 |
239 |
240 |
241 |
242 |
--------------------------------------------------------------------------------
/Chapter04/demoMultipleInheritance.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoMultipleInheritance.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(382, 322)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(11)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.lineEditName = QtWidgets.QLineEdit(Dialog)
22 | self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(11)
25 | self.lineEditName.setFont(font)
26 | self.lineEditName.setObjectName("lineEditName")
27 | self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
28 | self.ButtonClickMe.setGeometry(QtCore.QRect(150, 280, 101, 23))
29 | font = QtGui.QFont()
30 | font.setPointSize(11)
31 | self.ButtonClickMe.setFont(font)
32 | self.ButtonClickMe.setObjectName("ButtonClickMe")
33 | self.lineEditCode = QtWidgets.QLineEdit(Dialog)
34 | self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
35 | font = QtGui.QFont()
36 | font.setPointSize(11)
37 | self.lineEditCode.setFont(font)
38 | self.lineEditCode.setObjectName("lineEditCode")
39 | self.label_2 = QtWidgets.QLabel(Dialog)
40 | self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
41 | font = QtGui.QFont()
42 | font.setPointSize(11)
43 | self.label_2.setFont(font)
44 | self.label_2.setObjectName("label_2")
45 | self.lineEditHistoryMarks = QtWidgets.QLineEdit(Dialog)
46 | self.lineEditHistoryMarks.setGeometry(QtCore.QRect(140, 100, 201, 20))
47 | font = QtGui.QFont()
48 | font.setPointSize(11)
49 | self.lineEditHistoryMarks.setFont(font)
50 | self.lineEditHistoryMarks.setObjectName("lineEditHistoryMarks")
51 | self.label_3 = QtWidgets.QLabel(Dialog)
52 | self.label_3.setGeometry(QtCore.QRect(20, 100, 121, 20))
53 | font = QtGui.QFont()
54 | font.setPointSize(11)
55 | self.label_3.setFont(font)
56 | self.label_3.setObjectName("label_3")
57 | self.label_4 = QtWidgets.QLabel(Dialog)
58 | self.label_4.setGeometry(QtCore.QRect(20, 140, 121, 20))
59 | font = QtGui.QFont()
60 | font.setPointSize(11)
61 | self.label_4.setFont(font)
62 | self.label_4.setObjectName("label_4")
63 | self.lineEditGeographyMarks = QtWidgets.QLineEdit(Dialog)
64 | self.lineEditGeographyMarks.setGeometry(QtCore.QRect(140, 140, 201, 20))
65 | font = QtGui.QFont()
66 | font.setPointSize(11)
67 | self.lineEditGeographyMarks.setFont(font)
68 | self.lineEditGeographyMarks.setObjectName("lineEditGeographyMarks")
69 | self.lineEditPercentage = QtWidgets.QLineEdit(Dialog)
70 | self.lineEditPercentage.setEnabled(False)
71 | self.lineEditPercentage.setGeometry(QtCore.QRect(140, 220, 201, 20))
72 | font = QtGui.QFont()
73 | font.setPointSize(11)
74 | self.lineEditPercentage.setFont(font)
75 | self.lineEditPercentage.setObjectName("lineEditPercentage")
76 | self.label_5 = QtWidgets.QLabel(Dialog)
77 | self.label_5.setGeometry(QtCore.QRect(20, 220, 121, 20))
78 | font = QtGui.QFont()
79 | font.setPointSize(11)
80 | self.label_5.setFont(font)
81 | self.label_5.setObjectName("label_5")
82 | self.lineEditTotal = QtWidgets.QLineEdit(Dialog)
83 | self.lineEditTotal.setEnabled(False)
84 | self.lineEditTotal.setGeometry(QtCore.QRect(140, 180, 201, 20))
85 | font = QtGui.QFont()
86 | font.setPointSize(11)
87 | self.lineEditTotal.setFont(font)
88 | self.lineEditTotal.setObjectName("lineEditTotal")
89 | self.label_6 = QtWidgets.QLabel(Dialog)
90 | self.label_6.setGeometry(QtCore.QRect(20, 180, 121, 20))
91 | font = QtGui.QFont()
92 | font.setPointSize(11)
93 | self.label_6.setFont(font)
94 | self.label_6.setObjectName("label_6")
95 |
96 | self.retranslateUi(Dialog)
97 | QtCore.QMetaObject.connectSlotsByName(Dialog)
98 |
99 | def retranslateUi(self, Dialog):
100 | _translate = QtCore.QCoreApplication.translate
101 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
102 | self.label.setText(_translate("Dialog", "Student Name"))
103 | self.ButtonClickMe.setText(_translate("Dialog", "Click"))
104 | self.label_2.setText(_translate("Dialog", "Student Code"))
105 | self.label_3.setText(_translate("Dialog", "History Marks"))
106 | self.label_4.setText(_translate("Dialog", "Geography Marks"))
107 | self.label_5.setText(_translate("Dialog", "Percentage"))
108 | self.label_6.setText(_translate("Dialog", "Total"))
109 |
110 |
111 | if __name__ == "__main__":
112 | import sys
113 | app = QtWidgets.QApplication(sys.argv)
114 | Dialog = QtWidgets.QDialog()
115 | ui = Ui_Dialog()
116 | ui.setupUi(Dialog)
117 | Dialog.show()
118 | sys.exit(app.exec_())
119 |
120 |
--------------------------------------------------------------------------------
/Chapter04/demoSimpleInheritance.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoSimpleInheritance.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(402, 291)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(11)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.labelResponse = QtWidgets.QLabel(Dialog)
22 | self.labelResponse.setGeometry(QtCore.QRect(10, 179, 361, 41))
23 | font = QtGui.QFont()
24 | font.setPointSize(11)
25 | self.labelResponse.setFont(font)
26 | self.labelResponse.setText("")
27 | self.labelResponse.setObjectName("labelResponse")
28 | self.lineEditName = QtWidgets.QLineEdit(Dialog)
29 | self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
30 | font = QtGui.QFont()
31 | font.setPointSize(11)
32 | self.lineEditName.setFont(font)
33 | self.lineEditName.setObjectName("lineEditName")
34 | self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
35 | self.ButtonClickMe.setGeometry(QtCore.QRect(140, 250, 101, 23))
36 | font = QtGui.QFont()
37 | font.setPointSize(11)
38 | self.ButtonClickMe.setFont(font)
39 | self.ButtonClickMe.setObjectName("ButtonClickMe")
40 | self.lineEditCode = QtWidgets.QLineEdit(Dialog)
41 | self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
42 | font = QtGui.QFont()
43 | font.setPointSize(11)
44 | self.lineEditCode.setFont(font)
45 | self.lineEditCode.setObjectName("lineEditCode")
46 | self.label_2 = QtWidgets.QLabel(Dialog)
47 | self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
48 | font = QtGui.QFont()
49 | font.setPointSize(11)
50 | self.label_2.setFont(font)
51 | self.label_2.setObjectName("label_2")
52 | self.lineEditHistoryMarks = QtWidgets.QLineEdit(Dialog)
53 | self.lineEditHistoryMarks.setGeometry(QtCore.QRect(140, 100, 201, 20))
54 | font = QtGui.QFont()
55 | font.setPointSize(11)
56 | self.lineEditHistoryMarks.setFont(font)
57 | self.lineEditHistoryMarks.setObjectName("lineEditHistoryMarks")
58 | self.label_3 = QtWidgets.QLabel(Dialog)
59 | self.label_3.setGeometry(QtCore.QRect(20, 100, 121, 20))
60 | font = QtGui.QFont()
61 | font.setPointSize(11)
62 | self.label_3.setFont(font)
63 | self.label_3.setObjectName("label_3")
64 | self.label_4 = QtWidgets.QLabel(Dialog)
65 | self.label_4.setGeometry(QtCore.QRect(20, 140, 121, 20))
66 | font = QtGui.QFont()
67 | font.setPointSize(11)
68 | self.label_4.setFont(font)
69 | self.label_4.setObjectName("label_4")
70 | self.lineEditGeographyMarks = QtWidgets.QLineEdit(Dialog)
71 | self.lineEditGeographyMarks.setGeometry(QtCore.QRect(140, 140, 201, 20))
72 | font = QtGui.QFont()
73 | font.setPointSize(11)
74 | self.lineEditGeographyMarks.setFont(font)
75 | self.lineEditGeographyMarks.setObjectName("lineEditGeographyMarks")
76 |
77 | self.retranslateUi(Dialog)
78 | QtCore.QMetaObject.connectSlotsByName(Dialog)
79 |
80 | def retranslateUi(self, Dialog):
81 | _translate = QtCore.QCoreApplication.translate
82 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
83 | self.label.setText(_translate("Dialog", "Student Name"))
84 | self.ButtonClickMe.setText(_translate("Dialog", "Click"))
85 | self.label_2.setText(_translate("Dialog", "Student Code"))
86 | self.label_3.setText(_translate("Dialog", "History Marks"))
87 | self.label_4.setText(_translate("Dialog", "Geography Marks"))
88 |
89 |
90 | if __name__ == "__main__":
91 | import sys
92 | app = QtWidgets.QApplication(sys.argv)
93 | Dialog = QtWidgets.QDialog()
94 | ui = Ui_Dialog()
95 | ui.setupUi(Dialog)
96 | Dialog.show()
97 | sys.exit(app.exec_())
98 |
99 |
--------------------------------------------------------------------------------
/Chapter04/demoSimpleInheritance.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 402
10 | 291
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 60
21 | 121
22 | 20
23 |
24 |
25 |
26 |
27 | 11
28 |
29 |
30 |
31 | Student Name
32 |
33 |
34 |
35 |
36 |
37 | 10
38 | 179
39 | 361
40 | 41
41 |
42 |
43 |
44 |
45 | 11
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | 140
56 | 60
57 | 201
58 | 20
59 |
60 |
61 |
62 |
63 | 11
64 |
65 |
66 |
67 |
68 |
69 |
70 | 140
71 | 250
72 | 101
73 | 23
74 |
75 |
76 |
77 |
78 | 11
79 |
80 |
81 |
82 | Click
83 |
84 |
85 |
86 |
87 |
88 | 140
89 | 20
90 | 201
91 | 20
92 |
93 |
94 |
95 |
96 | 11
97 |
98 |
99 |
100 |
101 |
102 |
103 | 20
104 | 20
105 | 121
106 | 20
107 |
108 |
109 |
110 |
111 | 11
112 |
113 |
114 |
115 | Student Code
116 |
117 |
118 |
119 |
120 |
121 | 140
122 | 100
123 | 201
124 | 20
125 |
126 |
127 |
128 |
129 | 11
130 |
131 |
132 |
133 |
134 |
135 |
136 | 20
137 | 100
138 | 121
139 | 20
140 |
141 |
142 |
143 |
144 | 11
145 |
146 |
147 |
148 | History Marks
149 |
150 |
151 |
152 |
153 |
154 | 20
155 | 140
156 | 121
157 | 20
158 |
159 |
160 |
161 |
162 | 11
163 |
164 |
165 |
166 | Geography Marks
167 |
168 |
169 |
170 |
171 |
172 | 140
173 | 140
174 | 201
175 | 20
176 |
177 |
178 |
179 |
180 | 11
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
--------------------------------------------------------------------------------
/Chapter04/demoStudentClass.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoStudentClass.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(412, 208)
15 | self.label = QtWidgets.QLabel(Dialog)
16 | self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
17 | font = QtGui.QFont()
18 | font.setPointSize(11)
19 | self.label.setFont(font)
20 | self.label.setObjectName("label")
21 | self.labelResponse = QtWidgets.QLabel(Dialog)
22 | self.labelResponse.setGeometry(QtCore.QRect(30, 120, 361, 20))
23 | font = QtGui.QFont()
24 | font.setPointSize(11)
25 | self.labelResponse.setFont(font)
26 | self.labelResponse.setText("")
27 | self.labelResponse.setObjectName("labelResponse")
28 | self.lineEditName = QtWidgets.QLineEdit(Dialog)
29 | self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
30 | font = QtGui.QFont()
31 | font.setPointSize(11)
32 | self.lineEditName.setFont(font)
33 | self.lineEditName.setObjectName("lineEditName")
34 | self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
35 | self.ButtonClickMe.setGeometry(QtCore.QRect(140, 170, 101, 23))
36 | font = QtGui.QFont()
37 | font.setPointSize(11)
38 | self.ButtonClickMe.setFont(font)
39 | self.ButtonClickMe.setObjectName("ButtonClickMe")
40 | self.lineEditCode = QtWidgets.QLineEdit(Dialog)
41 | self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
42 | font = QtGui.QFont()
43 | font.setPointSize(11)
44 | self.lineEditCode.setFont(font)
45 | self.lineEditCode.setObjectName("lineEditCode")
46 | self.label_2 = QtWidgets.QLabel(Dialog)
47 | self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
48 | font = QtGui.QFont()
49 | font.setPointSize(11)
50 | self.label_2.setFont(font)
51 | self.label_2.setObjectName("label_2")
52 |
53 | self.retranslateUi(Dialog)
54 | QtCore.QMetaObject.connectSlotsByName(Dialog)
55 |
56 | def retranslateUi(self, Dialog):
57 | _translate = QtCore.QCoreApplication.translate
58 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
59 | self.label.setText(_translate("Dialog", "Student Name"))
60 | self.ButtonClickMe.setText(_translate("Dialog", "Click"))
61 | self.label_2.setText(_translate("Dialog", "Student Code"))
62 |
63 |
64 | if __name__ == "__main__":
65 | import sys
66 | app = QtWidgets.QApplication(sys.argv)
67 | Dialog = QtWidgets.QDialog()
68 | ui = Ui_Dialog()
69 | ui.setupUi(Dialog)
70 | Dialog.show()
71 | sys.exit(app.exec_())
72 |
73 |
--------------------------------------------------------------------------------
/Chapter04/demoStudentClass.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 412
10 | 208
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 60
21 | 121
22 | 20
23 |
24 |
25 |
26 |
27 | 11
28 |
29 |
30 |
31 | Student Name
32 |
33 |
34 |
35 |
36 |
37 | 30
38 | 120
39 | 361
40 | 20
41 |
42 |
43 |
44 |
45 | 11
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | 140
56 | 60
57 | 201
58 | 20
59 |
60 |
61 |
62 |
63 | 11
64 |
65 |
66 |
67 |
68 |
69 |
70 | 140
71 | 170
72 | 101
73 | 23
74 |
75 |
76 |
77 |
78 | 11
79 |
80 |
81 |
82 | Click
83 |
84 |
85 |
86 |
87 |
88 | 140
89 | 20
90 | 201
91 | 20
92 |
93 |
94 |
95 |
96 | 11
97 |
98 |
99 |
100 |
101 |
102 |
103 | 20
104 | 20
105 | 121
106 | 20
107 |
108 |
109 |
110 |
111 | 11
112 |
113 |
114 |
115 | Student Code
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/Chapter05/callColorDialog.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication, QColorDialog
4 | from PyQt5.QtGui import QColor
5 |
6 | from demoColorDialog import *
7 |
8 | class MyForm(QDialog):
9 | def __init__(self):
10 | super().__init__()
11 | col = QColor(0, 0, 0)
12 | self.ui = Ui_Dialog()
13 | self.ui.setupUi(self)
14 | self.ui.frameColor.setStyleSheet("QWidget { background-color: %s }" % col.name())
15 | self.ui.pushButtonColor.clicked.connect(self.dispcolor)
16 | self.show()
17 |
18 | def dispcolor(self):
19 | col = QColorDialog.getColor()
20 | if col.isValid():
21 | self.ui.frameColor.setStyleSheet("QWidget { background-color: %s }" % col.name())
22 | self.ui.labelColor.setText("You have selected the color with code: " + str(col.name()))
23 |
24 | if __name__=="__main__":
25 | app = QApplication(sys.argv)
26 | w = MyForm()
27 | w.show()
28 | sys.exit(app.exec_())
29 |
30 |
--------------------------------------------------------------------------------
/Chapter05/callFileDialog.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QMainWindow, QApplication, QAction, QFileDialog
4 |
5 | from demoFileDialog import *
6 |
7 | class MyForm(QMainWindow):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_MainWindow()
11 | self.ui.setupUi(self)
12 | self.ui.actionOpen.triggered.connect(self.openFileDialog)
13 | self.ui.actionSave.triggered.connect(self.saveFileDialog)
14 | self.show()
15 |
16 | def openFileDialog(self):
17 |
18 | fname = QFileDialog.getOpenFileName(self, 'Open file', '/home')
19 |
20 | if fname[0]:
21 | f = open(fname[0], 'r')
22 |
23 | with f:
24 | data = f.read()
25 | self.ui.textEdit.setText(data)
26 |
27 | def saveFileDialog(self):
28 | options = QFileDialog.Options()
29 | options |= QFileDialog.DontUseNativeDialog
30 | fileName, _ = QFileDialog.getSaveFileName(self,"QFileDialog.getSaveFileName()","","All Files (*);;Text Files (*.txt)", options=options)
31 | f = open(fileName,'w')
32 | text = self.ui.textEdit.toPlainText()
33 | f.write(text)
34 | f.close()
35 |
36 | if __name__=="__main__":
37 | app = QApplication(sys.argv)
38 | w = MyForm()
39 | w.show()
40 | sys.exit(app.exec_())
41 |
42 |
--------------------------------------------------------------------------------
/Chapter05/callFontDialog.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication, QFontDialog
4 |
5 |
6 | from demoFontDialog import *
7 |
8 | class MyForm(QDialog):
9 | def __init__(self):
10 | super().__init__()
11 | self.ui = Ui_Dialog()
12 | self.ui.setupUi(self)
13 | self.ui.pushButtonFont.clicked.connect(self.changefont)
14 | self.show()
15 |
16 | def changefont(self):
17 | font, ok = QFontDialog.getFont()
18 | if ok:
19 | self.ui.textEdit.setFont(font)
20 |
21 | if __name__=="__main__":
22 | app = QApplication(sys.argv)
23 | w = MyForm()
24 | w.show()
25 | sys.exit(app.exec_())
26 |
27 |
--------------------------------------------------------------------------------
/Chapter05/callInputDialog.pyw:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PyQt5.QtWidgets import QDialog, QApplication, QInputDialog
4 |
5 | from demoInputDialog import *
6 |
7 | class MyForm(QDialog):
8 | def __init__(self):
9 | super().__init__()
10 | self.ui = Ui_Dialog()
11 | self.ui.setupUi(self)
12 | self.ui.pushButtonCountry.clicked.connect(self.dispmessage)
13 | self.show()
14 |
15 | def dispmessage(self):
16 | countries = ("Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan")
17 | countryName, ok = QInputDialog.getItem(self, "Input Dialog", "List of countries", countries, 0, False)
18 | if ok and countryName:
19 | self.ui.lineEditCountry.setText(countryName)
20 |
21 | if __name__=="__main__":
22 | app = QApplication(sys.argv)
23 | w = MyForm()
24 | w.show()
25 | sys.exit(app.exec_())
26 |
27 |
--------------------------------------------------------------------------------
/Chapter05/demoColorDialog.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoColorDialog.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(400, 176)
15 | self.frameColor = QtWidgets.QFrame(Dialog)
16 | self.frameColor.setGeometry(QtCore.QRect(210, 20, 120, 80))
17 | font = QtGui.QFont()
18 | font.setPointSize(12)
19 | self.frameColor.setFont(font)
20 | self.frameColor.setFrameShape(QtWidgets.QFrame.StyledPanel)
21 | self.frameColor.setFrameShadow(QtWidgets.QFrame.Raised)
22 | self.frameColor.setObjectName("frameColor")
23 | self.pushButtonColor = QtWidgets.QPushButton(Dialog)
24 | self.pushButtonColor.setGeometry(QtCore.QRect(30, 40, 151, 23))
25 | font = QtGui.QFont()
26 | font.setPointSize(12)
27 | self.pushButtonColor.setFont(font)
28 | self.pushButtonColor.setObjectName("pushButtonColor")
29 | self.labelColor = QtWidgets.QLabel(Dialog)
30 | self.labelColor.setGeometry(QtCore.QRect(30, 130, 351, 20))
31 | font = QtGui.QFont()
32 | font.setPointSize(12)
33 | self.labelColor.setFont(font)
34 | self.labelColor.setText("")
35 | self.labelColor.setObjectName("labelColor")
36 |
37 | self.retranslateUi(Dialog)
38 | QtCore.QMetaObject.connectSlotsByName(Dialog)
39 |
40 | def retranslateUi(self, Dialog):
41 | _translate = QtCore.QCoreApplication.translate
42 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
43 | self.pushButtonColor.setText(_translate("Dialog", "Choose color"))
44 |
45 |
--------------------------------------------------------------------------------
/Chapter05/demoColorDialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 176
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 210
20 | 20
21 | 120
22 | 80
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | QFrame::StyledPanel
32 |
33 |
34 | QFrame::Raised
35 |
36 |
37 |
38 |
39 |
40 | 30
41 | 40
42 | 151
43 | 23
44 |
45 |
46 |
47 |
48 | 12
49 |
50 |
51 |
52 | Choose color
53 |
54 |
55 |
56 |
57 |
58 | 30
59 | 130
60 | 351
61 | 20
62 |
63 |
64 |
65 |
66 | 12
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/Chapter05/demoFileDialog.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoFileDialog.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_MainWindow(object):
12 | def setupUi(self, MainWindow):
13 | MainWindow.setObjectName("MainWindow")
14 | MainWindow.resize(516, 374)
15 | self.centralwidget = QtWidgets.QWidget(MainWindow)
16 | self.centralwidget.setObjectName("centralwidget")
17 | self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
18 | self.textEdit.setGeometry(QtCore.QRect(0, 10, 521, 331))
19 | self.textEdit.setObjectName("textEdit")
20 | MainWindow.setCentralWidget(self.centralwidget)
21 | self.menubar = QtWidgets.QMenuBar(MainWindow)
22 | self.menubar.setGeometry(QtCore.QRect(0, 0, 516, 21))
23 | self.menubar.setObjectName("menubar")
24 | self.menuFile = QtWidgets.QMenu(self.menubar)
25 | self.menuFile.setObjectName("menuFile")
26 | MainWindow.setMenuBar(self.menubar)
27 | self.statusbar = QtWidgets.QStatusBar(MainWindow)
28 | self.statusbar.setObjectName("statusbar")
29 | MainWindow.setStatusBar(self.statusbar)
30 | self.actionOpen = QtWidgets.QAction(MainWindow)
31 | self.actionOpen.setObjectName("actionOpen")
32 | self.actionSave = QtWidgets.QAction(MainWindow)
33 | self.actionSave.setObjectName("actionSave")
34 | self.menuFile.addAction(self.actionOpen)
35 | self.menuFile.addAction(self.actionSave)
36 | self.menubar.addAction(self.menuFile.menuAction())
37 |
38 | self.retranslateUi(MainWindow)
39 | QtCore.QMetaObject.connectSlotsByName(MainWindow)
40 |
41 | def retranslateUi(self, MainWindow):
42 | _translate = QtCore.QCoreApplication.translate
43 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
44 | self.menuFile.setTitle(_translate("MainWindow", "File"))
45 | self.actionOpen.setText(_translate("MainWindow", "Open"))
46 | self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O"))
47 | self.actionSave.setText(_translate("MainWindow", "Save"))
48 | self.actionSave.setShortcut(_translate("MainWindow", "Ctrl+S"))
49 |
50 |
--------------------------------------------------------------------------------
/Chapter05/demoFileDialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 544
10 | 386
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 0
21 | 10
22 | 521
23 | 331
24 |
25 |
26 |
27 |
28 |
46 |
47 |
48 |
49 | Open
50 |
51 |
52 | Ctrl+O
53 |
54 |
55 |
56 |
57 | Save
58 |
59 |
60 | Ctrl+S
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Chapter05/demoFontDialog.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoFontDialog.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(400, 300)
15 | self.textEdit = QtWidgets.QTextEdit(Dialog)
16 | self.textEdit.setGeometry(QtCore.QRect(30, 60, 331, 221))
17 | self.textEdit.setObjectName("textEdit")
18 | self.pushButtonFont = QtWidgets.QPushButton(Dialog)
19 | self.pushButtonFont.setGeometry(QtCore.QRect(120, 10, 111, 31))
20 | font = QtGui.QFont()
21 | font.setPointSize(12)
22 | self.pushButtonFont.setFont(font)
23 | self.pushButtonFont.setObjectName("pushButtonFont")
24 |
25 | self.retranslateUi(Dialog)
26 | QtCore.QMetaObject.connectSlotsByName(Dialog)
27 |
28 | def retranslateUi(self, Dialog):
29 | _translate = QtCore.QCoreApplication.translate
30 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
31 | self.pushButtonFont.setText(_translate("Dialog", "Change Font"))
32 |
33 |
--------------------------------------------------------------------------------
/Chapter05/demoFontDialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 30
20 | 60
21 | 331
22 | 221
23 |
24 |
25 |
26 |
27 |
28 |
29 | 120
30 | 10
31 | 111
32 | 31
33 |
34 |
35 |
36 |
37 | 12
38 |
39 |
40 |
41 | Change Font
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Chapter05/demoInputDialog.py:
--------------------------------------------------------------------------------
1 |
2 | from PyQt5 import QtCore, QtGui, QtWidgets
3 |
4 | class Ui_Dialog(object):
5 | def setupUi(self, Dialog):
6 | Dialog.setObjectName("Dialog")
7 | Dialog.resize(565, 74)
8 | self.label = QtWidgets.QLabel(Dialog)
9 | self.label.setGeometry(QtCore.QRect(20, 20, 131, 20))
10 | font = QtGui.QFont()
11 | font.setPointSize(12)
12 | self.label.setFont(font)
13 | self.label.setObjectName("label")
14 | self.lineEditCountry = QtWidgets.QLineEdit(Dialog)
15 | self.lineEditCountry.setGeometry(QtCore.QRect(140, 20, 221, 20))
16 | font = QtGui.QFont()
17 | font.setPointSize(12)
18 | self.lineEditCountry.setFont(font)
19 | self.lineEditCountry.setObjectName("lineEditCountry")
20 | self.pushButtonCountry = QtWidgets.QPushButton(Dialog)
21 | self.pushButtonCountry.setGeometry(QtCore.QRect(400, 20, 131, 23))
22 | font = QtGui.QFont()
23 | font.setPointSize(12)
24 | self.pushButtonCountry.setFont(font)
25 | self.pushButtonCountry.setObjectName("pushButtonCountry")
26 |
27 | self.retranslateUi(Dialog)
28 | QtCore.QMetaObject.connectSlotsByName(Dialog)
29 |
30 | def retranslateUi(self, Dialog):
31 | _translate = QtCore.QCoreApplication.translate
32 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
33 | self.label.setText(_translate("Dialog", "Your Country:"))
34 | self.pushButtonCountry.setText(_translate("Dialog", "Choose Country"))
35 |
36 |
37 | if __name__ == "__main__":
38 | import sys
39 | app = QtWidgets.QApplication(sys.argv)
40 | Dialog = QtWidgets.QDialog()
41 | ui = Ui_Dialog()
42 | ui.setupUi(Dialog)
43 | Dialog.show()
44 | sys.exit(app.exec_())
45 |
46 |
--------------------------------------------------------------------------------
/Chapter05/demoInputDialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 565
10 | 74
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 20
21 | 131
22 | 20
23 |
24 |
25 |
26 |
27 | 12
28 |
29 |
30 |
31 | Your Country:
32 |
33 |
34 |
35 |
36 |
37 | 140
38 | 20
39 | 221
40 | 20
41 |
42 |
43 |
44 |
45 | 12
46 |
47 |
48 |
49 |
50 |
51 |
52 | 400
53 | 20
54 | 131
55 | 23
56 |
57 |
58 |
59 |
60 | 12
61 |
62 |
63 |
64 | Choose Country
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/Chapter07/callServer.pyw:
--------------------------------------------------------------------------------
1 | import sys, time
2 | import socket
3 | from PyQt5 import QtGui
4 | from PyQt5 import QtCore
5 | from PyQt5.QtWidgets import QApplication, QDialog
6 | from PyQt5.QtCore import QCoreApplication
7 | from threading import Thread
8 | from socketserver import ThreadingMixIn
9 | from demoServer import *
10 |
11 | conn=None
12 |
13 | class Window(QDialog):
14 | def __init__(self):
15 | super().__init__()
16 | self.ui = Ui_Dialog()
17 | self.ui.setupUi(self)
18 | self.textEditMessages=self.ui.textEditMessages
19 | self.ui.pushButtonSend.clicked.connect(self.dispMessage)
20 | self.show()
21 |
22 | def dispMessage(self):
23 | text=self.ui.lineEditMessage.text()
24 | global conn
25 | conn.send(text.encode("utf-8"))
26 | self.ui.textEditMessages.append("Server: "+self.ui.lineEditMessage.text())
27 | self.ui.lineEditMessage.setText("")
28 |
29 | class ServerThread(Thread):
30 | def __init__(self,window):
31 | Thread.__init__(self)
32 | self.window=window
33 |
34 | def run(self):
35 | TCP_IP = '0.0.0.0'
36 | TCP_PORT = 80
37 | BUFFER_SIZE = 1024
38 | tcpServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
39 | tcpServer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
40 | tcpServer.bind((TCP_IP, TCP_PORT))
41 | threads = []
42 |
43 | tcpServer.listen(4)
44 | while True:
45 | global conn
46 | (conn, (ip,port)) = tcpServer.accept()
47 | newthread = ClientThread(ip,port,window)
48 | newthread.start()
49 | threads.append(newthread)
50 |
51 | for t in threads:
52 | t.join()
53 |
54 |
55 | class ClientThread(Thread):
56 |
57 | def __init__(self,ip,port,window):
58 | Thread.__init__(self)
59 | self.window=window
60 | self.ip = ip
61 | self.port = port
62 |
63 |
64 | def run(self):
65 | while True :
66 | global conn
67 | data = conn.recv(1024)
68 | window.textEditMessages.append("Client: "+data.decode("utf-8"))
69 |
70 | if __name__=="__main__":
71 | app = QApplication(sys.argv)
72 | window = Window()
73 | serverThread=ServerThread(window)
74 | serverThread.start()
75 | window.exec()
76 | sys.exit(app.exec_())
77 |
--------------------------------------------------------------------------------
/Chapter07/demoBrowser.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoBrowser.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_Dialog(object):
12 | def setupUi(self, Dialog):
13 | Dialog.setObjectName("Dialog")
14 | Dialog.resize(563, 339)
15 | self.widget = QWebEngineView(Dialog)
16 | self.widget.setGeometry(QtCore.QRect(10, 60, 531, 251))
17 | self.widget.setObjectName("widget")
18 | self.pushButtonGo = QtWidgets.QPushButton(Dialog)
19 | self.pushButtonGo.setGeometry(QtCore.QRect(450, 20, 91, 23))
20 | font = QtGui.QFont()
21 | font.setPointSize(12)
22 | self.pushButtonGo.setFont(font)
23 | self.pushButtonGo.setObjectName("pushButtonGo")
24 | self.lineEditURL = QtWidgets.QLineEdit(Dialog)
25 | self.lineEditURL.setGeometry(QtCore.QRect(100, 20, 331, 21))
26 | font = QtGui.QFont()
27 | font.setPointSize(12)
28 | self.lineEditURL.setFont(font)
29 | self.lineEditURL.setObjectName("lineEditURL")
30 | self.label = QtWidgets.QLabel(Dialog)
31 | self.label.setGeometry(QtCore.QRect(10, 20, 71, 16))
32 | font = QtGui.QFont()
33 | font.setPointSize(12)
34 | self.label.setFont(font)
35 | self.label.setObjectName("label")
36 |
37 | self.retranslateUi(Dialog)
38 | QtCore.QMetaObject.connectSlotsByName(Dialog)
39 |
40 | def retranslateUi(self, Dialog):
41 | _translate = QtCore.QCoreApplication.translate
42 | Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
43 | self.pushButtonGo.setText(_translate("Dialog", "Go"))
44 | self.label.setText(_translate("Dialog", "Enter URL"))
45 |
46 | from PyQt5.QtWebEngineWidgets import QWebEngineView
47 |
48 | if __name__ == "__main__":
49 | import sys
50 | app = QtWidgets.QApplication(sys.argv)
51 | Dialog = QtWidgets.QDialog()
52 | ui = Ui_Dialog()
53 | ui.setupUi(Dialog)
54 | Dialog.show()
55 | sys.exit(app.exec_())
56 |
57 |
--------------------------------------------------------------------------------
/Chapter07/demoDockWidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 637
10 | 440
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
27 |
28 |
29 |
30 | QDockWidget::AllDockWidgetFeatures
31 |
32 |
33 | Qt::AllDockWidgetAreas
34 |
35 |
36 | Dockable Sign In Form
37 |
38 |
39 | 1
40 |
41 |
42 |
43 |
44 |
45 | 130
46 | 10
47 | 91
48 | 21
49 |
50 |
51 |
52 |
53 | 12
54 |
55 |
56 |
57 | Sign In
58 |
59 |
60 |
61 |
62 |
63 | 10
64 | 60
65 | 111
66 | 20
67 |
68 |
69 |
70 |
71 | 12
72 |
73 |
74 |
75 | Email Address
76 |
77 |
78 |
79 |
80 |
81 | 120
82 | 60
83 | 161
84 | 20
85 |
86 |
87 |
88 |
89 | 12
90 |
91 |
92 |
93 |
94 |
95 |
96 | 20
97 | 110
98 | 81
99 | 16
100 |
101 |
102 |
103 |
104 | 12
105 |
106 |
107 |
108 | Password
109 |
110 |
111 |
112 |
113 |
114 | 100
115 | 150
116 | 75
117 | 23
118 |
119 |
120 |
121 |
122 | 12
123 |
124 |
125 |
126 | Sign In
127 |
128 |
129 |
130 |
131 |
132 | 120
133 | 110
134 | 151
135 | 20
136 |
137 |
138 |
139 |
140 | 12
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/Chapter07/demoMenuBar.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'demoMenuBar.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.6
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 |
11 | class Ui_MainWindow(object):
12 | def setupUi(self, MainWindow):
13 | MainWindow.setObjectName("MainWindow")
14 | MainWindow.resize(463, 341)
15 | self.centralwidget = QtWidgets.QWidget(MainWindow)
16 | self.centralwidget.setObjectName("centralwidget")
17 | self.label = QtWidgets.QLabel(self.centralwidget)
18 | self.label.setGeometry(QtCore.QRect(20, 110, 421, 20))
19 | font = QtGui.QFont()
20 | font.setPointSize(12)
21 | self.label.setFont(font)
22 | self.label.setText("")
23 | self.label.setObjectName("label")
24 | MainWindow.setCentralWidget(self.centralwidget)
25 | self.menubar = QtWidgets.QMenuBar(MainWindow)
26 | self.menubar.setGeometry(QtCore.QRect(0, 0, 463, 21))
27 | self.menubar.setObjectName("menubar")
28 | self.menuDraw = QtWidgets.QMenu(self.menubar)
29 | self.menuDraw.setObjectName("menuDraw")
30 | self.menuProperties = QtWidgets.QMenu(self.menuDraw)
31 | self.menuProperties.setObjectName("menuProperties")
32 | self.menuEdit = QtWidgets.QMenu(self.menubar)
33 | self.menuEdit.setObjectName("menuEdit")
34 | MainWindow.setMenuBar(self.menubar)
35 | self.statusbar = QtWidgets.QStatusBar(MainWindow)
36 | self.statusbar.setObjectName("statusbar")
37 | MainWindow.setStatusBar(self.statusbar)
38 | self.actionDraw_Circle = QtWidgets.QAction(MainWindow)
39 | self.actionDraw_Circle.setObjectName("actionDraw_Circle")
40 | self.actionDraw_Rectangle = QtWidgets.QAction(MainWindow)
41 | self.actionDraw_Rectangle.setObjectName("actionDraw_Rectangle")
42 | self.actionDraw_Line = QtWidgets.QAction(MainWindow)
43 | self.actionDraw_Line.setObjectName("actionDraw_Line")
44 | self.actionPage_Setup = QtWidgets.QAction(MainWindow)
45 | self.actionPage_Setup.setObjectName("actionPage_Setup")
46 | self.actionSet_Password = QtWidgets.QAction(MainWindow)
47 | self.actionSet_Password.setCheckable(True)
48 | self.actionSet_Password.setObjectName("actionSet_Password")
49 | self.actionCut = QtWidgets.QAction(MainWindow)
50 | self.actionCut.setObjectName("actionCut")
51 | self.actionCopy = QtWidgets.QAction(MainWindow)
52 | self.actionCopy.setObjectName("actionCopy")
53 | self.actionPaste = QtWidgets.QAction(MainWindow)
54 | self.actionPaste.setObjectName("actionPaste")
55 | self.menuProperties.addAction(self.actionPage_Setup)
56 | self.menuProperties.addAction(self.actionSet_Password)
57 | self.menuDraw.addAction(self.actionDraw_Circle)
58 | self.menuDraw.addAction(self.actionDraw_Rectangle)
59 | self.menuDraw.addAction(self.actionDraw_Line)
60 | self.menuDraw.addSeparator()
61 | self.menuDraw.addAction(self.menuProperties.menuAction())
62 | self.menuEdit.addAction(self.actionCut)
63 | self.menuEdit.addAction(self.actionCopy)
64 | self.menuEdit.addAction(self.actionPaste)
65 | self.menubar.addAction(self.menuDraw.menuAction())
66 | self.menubar.addAction(self.menuEdit.menuAction())
67 |
68 | self.retranslateUi(MainWindow)
69 | QtCore.QMetaObject.connectSlotsByName(MainWindow)
70 |
71 | def retranslateUi(self, MainWindow):
72 | _translate = QtCore.QCoreApplication.translate
73 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
74 | self.menuDraw.setTitle(_translate("MainWindow", "Draw"))
75 | self.menuProperties.setTitle(_translate("MainWindow", "Properties"))
76 | self.menuEdit.setTitle(_translate("MainWindow", "Edit"))
77 | self.actionDraw_Circle.setText(_translate("MainWindow", "Draw Circle"))
78 | self.actionDraw_Circle.setToolTip(_translate("MainWindow", "To draw a circle"))
79 | self.actionDraw_Circle.setShortcut(_translate("MainWindow", "Shift+C"))
80 | self.actionDraw_Rectangle.setText(_translate("MainWindow", "Draw Rectangle"))
81 | self.actionDraw_Rectangle.setShortcut(_translate("MainWindow", "Ctrl+R"))
82 | self.actionDraw_Line.setText(_translate("MainWindow", "Draw Line"))
83 | self.actionDraw_Line.setShortcut(_translate("MainWindow", "Ctrl+L"))
84 | self.actionPage_Setup.setText(_translate("MainWindow", "Page Setup"))
85 | self.actionPage_Setup.setShortcut(_translate("MainWindow", "Shift+S"))
86 | self.actionSet_Password.setText(_translate("MainWindow", "Set Password"))
87 | self.actionSet_Password.setShortcut(_translate("MainWindow", "Shift+P"))
88 | self.actionCut.setText(_translate("MainWindow", "Cut"))
89 | self.actionCut.setShortcut(_translate("MainWindow", "Ctrl+X"))
90 | self.actionCopy.setText(_translate("MainWindow", "Copy"))
91 | self.actionCopy.setShortcut(_translate("MainWindow", "Ctrl+C"))
92 | self.actionPaste.setText(_translate("MainWindow", "Paste"))
93 | self.actionPaste.setShortcut(_translate("MainWindow", "Ctrl+V"))
94 |
95 |
96 | if __name__ == "__main__":
97 | import sys
98 | app = QtWidgets.QApplication(sys.argv)
99 | MainWindow = QtWidgets.QMainWindow()
100 | ui = Ui_MainWindow()
101 | ui.setupUi(MainWindow)
102 | MainWindow.show()
103 | sys.exit(app.exec_())
104 |
105 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Packt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------