Showing preview only (243K chars total). Download the full file or copy to clipboard to get everything.
Repository: PacktPublishing/Qt5-Python-GUI-Programming-Cookbook
Branch: master
Commit: 2faa44cd090e
Files: 94
Total size: 220.9 KB
Directory structure:
gitextract_2qkmchcu/
├── Chapter01/
│ ├── 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/
│ ├── 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
================================================
FILE CONTENTS
================================================
================================================
FILE: Chapter01/callCheckBox1.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtCore import pyqtSlot
from demoCheckBox1 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.checkBoxCheese.stateChanged.connect(self.dispAmount)
self.ui.checkBoxOlives.stateChanged.connect(self.dispAmount)
self.ui.checkBoxSausages.stateChanged.connect(self.dispAmount)
self.show()
@pyqtSlot()
def dispAmount(self):
amount=10
if self.ui.checkBoxCheese.isChecked()==True:
amount=amount+1
if self.ui.checkBoxOlives.isChecked()==True:
amount=amount+1
if self.ui.checkBoxSausages.isChecked()==True:
amount=amount+2
self.ui.labelAmount.setText("Total amount for pizza is "+str(amount))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter01/callCheckBox2.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtCore import pyqtSlot
from demoCheckBox2 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.checkBoxChoclateAlmond.stateChanged.connect(self.dispAmount)
self.ui.checkBoxChoclateChips.stateChanged.connect(self.dispAmount)
self.ui.checkBoxCookieDough.stateChanged.connect(self.dispAmount)
self.ui.checkBoxRockyRoad.stateChanged.connect(self.dispAmount)
self.ui.checkBoxCoffee.stateChanged.connect(self.dispAmount)
self.ui.checkBoxSoda.stateChanged.connect(self.dispAmount)
self.ui.checkBoxTea.stateChanged.connect(self.dispAmount)
self.show()
@pyqtSlot()
def dispAmount(self):
amount=0
if self.ui.checkBoxChoclateAlmond.isChecked()==True:
amount=amount+3
if self.ui.checkBoxChoclateChips.isChecked()==True:
amount=amount+4
if self.ui.checkBoxCookieDough.isChecked()==True:
amount=amount+2
if self.ui.checkBoxRockyRoad.isChecked()==True:
amount=amount+5
if self.ui.checkBoxCoffee.isChecked()==True:
amount=amount+2
if self.ui.checkBoxSoda.isChecked()==True:
amount=amount+3
if self.ui.checkBoxTea.isChecked()==True:
amount=amount+1
self.ui.labelAmount.setText("Total amount is $"+str(amount))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter01/callLineEdit.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoLineEdit import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
self.show()
def dispmessage(self):
self.ui.labelResponse.setText("Hello "+self.ui.lineEditName.text())
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter01/callRadioButton1.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoRadioButton1 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.radioButtonFirstClass.toggled.connect(self.dispFare)
self.ui.radioButtonBusinessClass.toggled.connect(self.dispFare)
self.ui.radioButtonEconomyClass.toggled.connect(self.dispFare)
self.show()
def dispFare(self):
fare=0
if self.ui.radioButtonFirstClass.isChecked()==True:
fare=150
if self.ui.radioButtonBusinessClass.isChecked()==True:
fare=125
if self.ui.radioButtonEconomyClass.isChecked()==True:
fare=100
self.ui.labelFare.setText("Air Fare is "+str(fare))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter01/callRadioButton2.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoRadioButton2 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.radioButtonMedium.toggled.connect(self.dispSelected)
self.ui.radioButtonLarge.toggled.connect(self.dispSelected)
self.ui.radioButtonXL.toggled.connect(self.dispSelected)
self.ui.radioButtonXXL.toggled.connect(self.dispSelected)
self.ui.radioButtonDebitCard.toggled.connect(self.dispSelected)
self.ui.radioButtonNetBanking.toggled.connect(self.dispSelected)
self.ui.radioButtonCashOnDelivery.toggled.connect(self.dispSelected)
self.show()
def dispSelected(self):
selected1="";
selected2=""
if self.ui.radioButtonMedium.isChecked()==True:
selected1="Medium"
if self.ui.radioButtonLarge.isChecked()==True:
selected1="Large"
if self.ui.radioButtonXL.isChecked()==True:
selected1="Extra Large"
if self.ui.radioButtonXXL.isChecked()==True:
selected1="Extra Extra Large"
if self.ui.radioButtonDebitCard.isChecked()==True:
selected2="Debit/Credit Card"
if self.ui.radioButtonNetBanking.isChecked()==True:
selected2="NetBanking"
if self.ui.radioButtonCashOnDelivery.isChecked()==True:
selected2="Cash On Delivery"
self.ui.labelSelected.setText("Chosen shirt size is "+selected1+" and payment method as " + selected2)
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter01/demoCheckBox1.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoCheckBox1.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(503, 272)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(130, 0, 221, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 50, 251, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.checkBoxCheese = QtWidgets.QCheckBox(Dialog)
self.checkBoxCheese.setGeometry(QtCore.QRect(270, 60, 191, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxCheese.setFont(font)
self.checkBoxCheese.setObjectName("checkBoxCheese")
self.checkBoxOlives = QtWidgets.QCheckBox(Dialog)
self.checkBoxOlives.setGeometry(QtCore.QRect(270, 90, 241, 21))
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxOlives.setFont(font)
self.checkBoxOlives.setObjectName("checkBoxOlives")
self.checkBoxSausages = QtWidgets.QCheckBox(Dialog)
self.checkBoxSausages.setGeometry(QtCore.QRect(270, 120, 231, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxSausages.setFont(font)
self.checkBoxSausages.setObjectName("checkBoxSausages")
self.labelAmount = QtWidgets.QLabel(Dialog)
self.labelAmount.setGeometry(QtCore.QRect(50, 190, 371, 20))
font = QtGui.QFont()
font.setPointSize(14)
self.labelAmount.setFont(font)
self.labelAmount.setObjectName("labelAmount")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Regular Pizza $10"))
self.label_2.setText(_translate("Dialog", "Select your extra toppings"))
self.checkBoxCheese.setText(_translate("Dialog", "Extra Cheese $1"))
self.checkBoxOlives.setText(_translate("Dialog", "Extra Olives $1"))
self.checkBoxSausages.setText(_translate("Dialog", "Extra Sausages $2"))
self.labelAmount.setText(_translate("Dialog", "TextLabel"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter01/demoCheckBox2.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoCheckbox2.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(646, 537)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(250, 0, 71, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 80, 181, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.labelDrinks = QtWidgets.QLabel(Dialog)
self.labelDrinks.setGeometry(QtCore.QRect(40, 290, 151, 20))
font = QtGui.QFont()
font.setPointSize(14)
self.labelDrinks.setFont(font)
self.labelDrinks.setObjectName("labelDrinks")
self.groupBoxIceCreams = QtWidgets.QGroupBox(Dialog)
self.groupBoxIceCreams.setGeometry(QtCore.QRect(230, 60, 241, 181))
self.groupBoxIceCreams.setCheckable(True)
self.groupBoxIceCreams.setObjectName("groupBoxIceCreams")
self.layoutWidget = QtWidgets.QWidget(self.groupBoxIceCreams)
self.layoutWidget.setGeometry(QtCore.QRect(10, 30, 221, 62))
self.layoutWidget.setObjectName("layoutWidget")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.layoutWidget)
self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.checkBoxChoclateChips = QtWidgets.QCheckBox(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxChoclateChips.setFont(font)
self.checkBoxChoclateChips.setObjectName("checkBoxChoclateChips")
self.verticalLayout_3.addWidget(self.checkBoxChoclateChips)
self.checkBoxCookieDough = QtWidgets.QCheckBox(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxCookieDough.setFont(font)
self.checkBoxCookieDough.setObjectName("checkBoxCookieDough")
self.verticalLayout_3.addWidget(self.checkBoxCookieDough)
self.layoutWidget1 = QtWidgets.QWidget(self.groupBoxIceCreams)
self.layoutWidget1.setGeometry(QtCore.QRect(10, 100, 213, 62))
self.layoutWidget1.setObjectName("layoutWidget1")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.layoutWidget1)
self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.checkBoxChoclateAlmond = QtWidgets.QCheckBox(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxChoclateAlmond.setFont(font)
self.checkBoxChoclateAlmond.setObjectName("checkBoxChoclateAlmond")
self.verticalLayout_4.addWidget(self.checkBoxChoclateAlmond)
self.checkBoxRockyRoad = QtWidgets.QCheckBox(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxRockyRoad.setFont(font)
self.checkBoxRockyRoad.setObjectName("checkBoxRockyRoad")
self.verticalLayout_4.addWidget(self.checkBoxRockyRoad)
self.groupBoxDrinks = QtWidgets.QGroupBox(Dialog)
self.groupBoxDrinks.setGeometry(QtCore.QRect(230, 280, 181, 151))
self.groupBoxDrinks.setCheckable(True)
self.groupBoxDrinks.setObjectName("groupBoxDrinks")
self.layoutWidget2 = QtWidgets.QWidget(self.groupBoxDrinks)
self.layoutWidget2.setGeometry(QtCore.QRect(10, 30, 110, 95))
self.layoutWidget2.setObjectName("layoutWidget2")
self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget2)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.checkBoxCoffee = QtWidgets.QCheckBox(self.layoutWidget2)
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxCoffee.setFont(font)
self.checkBoxCoffee.setObjectName("checkBoxCoffee")
self.verticalLayout.addWidget(self.checkBoxCoffee)
self.checkBoxSoda = QtWidgets.QCheckBox(self.layoutWidget2)
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxSoda.setFont(font)
self.checkBoxSoda.setObjectName("checkBoxSoda")
self.verticalLayout.addWidget(self.checkBoxSoda)
self.checkBoxTea = QtWidgets.QCheckBox(self.layoutWidget2)
font = QtGui.QFont()
font.setPointSize(14)
self.checkBoxTea.setFont(font)
self.checkBoxTea.setObjectName("checkBoxTea")
self.verticalLayout.addWidget(self.checkBoxTea)
self.labelAmount = QtWidgets.QLabel(Dialog)
self.labelAmount.setGeometry(QtCore.QRect(60, 450, 541, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.labelAmount.setFont(font)
self.labelAmount.setText("")
self.labelAmount.setObjectName("labelAmount")
self.groupBoxIceCreams.raise_()
self.groupBoxDrinks.raise_()
self.label.raise_()
self.label_2.raise_()
self.labelDrinks.raise_()
self.labelAmount.raise_()
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Menu"))
self.label_2.setText(_translate("Dialog", "Select your IceCream"))
self.labelDrinks.setText(_translate("Dialog", "Select your drink"))
self.groupBoxIceCreams.setTitle(_translate("Dialog", "IceCreams"))
self.checkBoxChoclateChips.setText(_translate("Dialog", "Mint Choclate Chips $4"))
self.checkBoxCookieDough.setText(_translate("Dialog", "Cookie Dough $2"))
self.checkBoxChoclateAlmond.setText(_translate("Dialog", "Chocolate Almond $3"))
self.checkBoxRockyRoad.setText(_translate("Dialog", "Rocky Road $5"))
self.groupBoxDrinks.setTitle(_translate("Dialog", "Drinks"))
self.checkBoxCoffee.setText(_translate("Dialog", "Coffee $2"))
self.checkBoxSoda.setText(_translate("Dialog", "Soda $3"))
self.checkBoxTea.setText(_translate("Dialog", "Tea $1"))
================================================
FILE: Chapter01/demoCheckbox1.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>503</width>
<height>272</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>130</x>
<y>0</y>
<width>221</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Regular Pizza $10</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Select your extra toppings</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxCheese">
<property name="geometry">
<rect>
<x>270</x>
<y>60</y>
<width>191</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Extra Cheese $1</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxOlives">
<property name="geometry">
<rect>
<x>270</x>
<y>90</y>
<width>241</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Extra Olives $1</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSausages">
<property name="geometry">
<rect>
<x>270</x>
<y>120</y>
<width>231</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Extra Sausages $2</string>
</property>
</widget>
<widget class="QLabel" name="labelAmount">
<property name="geometry">
<rect>
<x>50</x>
<y>190</y>
<width>371</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter01/demoCheckbox2.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>646</width>
<height>537</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>250</x>
<y>0</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Menu</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>80</y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Select your IceCream</string>
</property>
</widget>
<widget class="QLabel" name="labelDrinks">
<property name="geometry">
<rect>
<x>40</x>
<y>290</y>
<width>151</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Select your drink</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBoxIceCreams">
<property name="geometry">
<rect>
<x>230</x>
<y>60</y>
<width>241</width>
<height>181</height>
</rect>
</property>
<property name="title">
<string>IceCreams</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>221</width>
<height>62</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="checkBoxChoclateChips">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Mint Choclate Chips $4</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxCookieDough">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Cookie Dough $2</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>213</width>
<height>62</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="checkBoxChoclateAlmond">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Chocolate Almond $3</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxRockyRoad">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Rocky Road $5</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBoxDrinks">
<property name="geometry">
<rect>
<x>230</x>
<y>280</y>
<width>181</width>
<height>151</height>
</rect>
</property>
<property name="title">
<string>Drinks</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>110</width>
<height>95</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBoxCoffee">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Coffee $2</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSoda">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Soda $3</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxTea">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Tea $1</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QLabel" name="labelAmount">
<property name="geometry">
<rect>
<x>60</x>
<y>450</y>
<width>541</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<zorder>groupBoxIceCreams</zorder>
<zorder>groupBoxDrinks</zorder>
<zorder>label</zorder>
<zorder>label_2</zorder>
<zorder>labelDrinks</zorder>
<zorder>labelAmount</zorder>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter01/demoLineEdit.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoLineEdit.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(379, 195)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(6, 40, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label.setFont(font)
self.label.setObjectName("label")
self.labelResponse = QtWidgets.QLabel(Dialog)
self.labelResponse.setGeometry(QtCore.QRect(40, 90, 271, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.labelResponse.setFont(font)
self.labelResponse.setObjectName("labelResponse")
self.lineEditName = QtWidgets.QLineEdit(Dialog)
self.lineEditName.setGeometry(QtCore.QRect(140, 40, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditName.setFont(font)
self.lineEditName.setObjectName("lineEditName")
self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
self.ButtonClickMe.setGeometry(QtCore.QRect(160, 130, 101, 23))
font = QtGui.QFont()
font.setPointSize(11)
self.ButtonClickMe.setFont(font)
self.ButtonClickMe.setObjectName("ButtonClickMe")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Enter your name"))
self.labelResponse.setText(_translate("Dialog", "TextLabel"))
self.ButtonClickMe.setText(_translate("Dialog", "Click"))
================================================
FILE: Chapter01/demoLineEdit.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>379</width>
<height>195</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>6</x>
<y>40</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Enter your name</string>
</property>
</widget>
<widget class="QLabel" name="labelResponse">
<property name="geometry">
<rect>
<x>40</x>
<y>90</y>
<width>271</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>140</x>
<y>40</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="ButtonClickMe">
<property name="geometry">
<rect>
<x>160</x>
<y>130</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Click</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter01/demoRadioButton1.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoRadioButton1.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(470, 290)
self.radioButtonBusinessClass = QtWidgets.QRadioButton(Dialog)
self.radioButtonBusinessClass.setGeometry(QtCore.QRect(30, 130, 251, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonBusinessClass.setFont(font)
self.radioButtonBusinessClass.setObjectName("radioButtonBusinessClass")
self.radioButtonEconomyClass = QtWidgets.QRadioButton(Dialog)
self.radioButtonEconomyClass.setGeometry(QtCore.QRect(30, 180, 221, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonEconomyClass.setFont(font)
self.radioButtonEconomyClass.setObjectName("radioButtonEconomyClass")
self.radioButtonFirstClass = QtWidgets.QRadioButton(Dialog)
self.radioButtonFirstClass.setGeometry(QtCore.QRect(30, 80, 201, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonFirstClass.setFont(font)
self.radioButtonFirstClass.setObjectName("radioButtonFirstClass")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(80, 10, 261, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.labelFare = QtWidgets.QLabel(Dialog)
self.labelFare.setGeometry(QtCore.QRect(40, 245, 391, 21))
font = QtGui.QFont()
font.setPointSize(14)
self.labelFare.setFont(font)
self.labelFare.setText("")
self.labelFare.setObjectName("labelFare")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.radioButtonBusinessClass.setText(_translate("Dialog", "Business Class $125"))
self.radioButtonEconomyClass.setText(_translate("Dialog", "Economy Class $100"))
self.radioButtonFirstClass.setText(_translate("Dialog", "First Class $150"))
self.label.setText(_translate("Dialog", "Choose the flight type"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter01/demoRadioButton1.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>470</width>
<height>290</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QRadioButton" name="radioButtonBusinessClass">
<property name="geometry">
<rect>
<x>30</x>
<y>130</y>
<width>251</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Business Class $125</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButtonEconomyClass">
<property name="geometry">
<rect>
<x>30</x>
<y>180</y>
<width>221</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Economy Class $100</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButtonFirstClass">
<property name="geometry">
<rect>
<x>30</x>
<y>80</y>
<width>201</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>First Class $150</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>261</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Choose the flight type</string>
</property>
</widget>
<widget class="QLabel" name="labelFare">
<property name="geometry">
<rect>
<x>40</x>
<y>245</y>
<width>391</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter01/demoRadioButton2.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoRadioButton2.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(730, 452)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(100, 10, 221, 21))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(100, 210, 261, 41))
font = QtGui.QFont()
font.setPointSize(14)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.labelSelected = QtWidgets.QLabel(Dialog)
self.labelSelected.setGeometry(QtCore.QRect(20, 380, 691, 41))
font = QtGui.QFont()
font.setPointSize(14)
self.labelSelected.setFont(font)
self.labelSelected.setText("")
self.labelSelected.setObjectName("labelSelected")
self.layoutWidget = QtWidgets.QWidget(Dialog)
self.layoutWidget.setGeometry(QtCore.QRect(100, 50, 56, 128))
self.layoutWidget.setObjectName("layoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.radioButtonMedium = QtWidgets.QRadioButton(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonMedium.setFont(font)
self.radioButtonMedium.setObjectName("radioButtonMedium")
self.verticalLayout.addWidget(self.radioButtonMedium)
self.radioButtonLarge = QtWidgets.QRadioButton(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonLarge.setFont(font)
self.radioButtonLarge.setObjectName("radioButtonLarge")
self.verticalLayout.addWidget(self.radioButtonLarge)
self.radioButtonXL = QtWidgets.QRadioButton(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonXL.setFont(font)
self.radioButtonXL.setObjectName("radioButtonXL")
self.verticalLayout.addWidget(self.radioButtonXL)
self.radioButtonXXL = QtWidgets.QRadioButton(self.layoutWidget)
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonXXL.setFont(font)
self.radioButtonXXL.setObjectName("radioButtonXXL")
self.verticalLayout.addWidget(self.radioButtonXXL)
self.layoutWidget1 = QtWidgets.QWidget(Dialog)
self.layoutWidget1.setGeometry(QtCore.QRect(100, 260, 170, 95))
self.layoutWidget1.setObjectName("layoutWidget1")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.layoutWidget1)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.radioButtonDebitCard = QtWidgets.QRadioButton(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonDebitCard.setFont(font)
self.radioButtonDebitCard.setObjectName("radioButtonDebitCard")
self.verticalLayout_2.addWidget(self.radioButtonDebitCard)
self.radioButtonNetBanking = QtWidgets.QRadioButton(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonNetBanking.setFont(font)
self.radioButtonNetBanking.setObjectName("radioButtonNetBanking")
self.verticalLayout_2.addWidget(self.radioButtonNetBanking)
self.radioButtonCashOnDelivery = QtWidgets.QRadioButton(self.layoutWidget1)
font = QtGui.QFont()
font.setPointSize(14)
self.radioButtonCashOnDelivery.setFont(font)
self.radioButtonCashOnDelivery.setObjectName("radioButtonCashOnDelivery")
self.verticalLayout_2.addWidget(self.radioButtonCashOnDelivery)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Choose your Shirt Size"))
self.label_2.setText(_translate("Dialog", "Choose your payment method"))
self.radioButtonMedium.setText(_translate("Dialog", "M"))
self.radioButtonLarge.setText(_translate("Dialog", "L"))
self.radioButtonXL.setText(_translate("Dialog", "XL"))
self.radioButtonXXL.setText(_translate("Dialog", "XXL"))
self.radioButtonDebitCard.setText(_translate("Dialog", "Debit/Credit Card"))
self.radioButtonNetBanking.setText(_translate("Dialog", "NetBanking"))
self.radioButtonCashOnDelivery.setText(_translate("Dialog", "Cash On Delivery"))
================================================
FILE: Chapter01/demoRadioButton2.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>452</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>100</x>
<y>10</y>
<width>221</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Choose your Shirt Size</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>100</x>
<y>210</y>
<width>261</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Choose your payment method</string>
</property>
</widget>
<widget class="QLabel" name="labelSelected">
<property name="geometry">
<rect>
<x>20</x>
<y>380</y>
<width>691</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>100</x>
<y>50</y>
<width>56</width>
<height>128</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="radioButtonMedium">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>M</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLarge">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>L</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonXL">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>XL</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonXXL">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>XXL</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>100</x>
<y>260</y>
<width>170</width>
<height>95</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="radioButtonDebitCard">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Debit/Credit Card</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonNetBanking">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>NetBanking</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonCashOnDelivery">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Cash On Delivery</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/callCalculator.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoCalculator import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.pushButtonPlus.clicked.connect(self.addtwonum)
self.ui.pushButtonSubtract.clicked.connect(self.subtracttwonum)
self.ui.pushButtonMultiply.clicked.connect(self.multiplytwonum)
self.ui.pushButtonDivide.clicked.connect(self.dividetwonum)
self.show()
def addtwonum(self):
if len(self.ui.lineEditFirstNumber.text())!=0:
a=int(self.ui.lineEditFirstNumber.text())
else:
a=0
if len(self.ui.lineEditSecondNumber.text())!=0:
b=int(self.ui.lineEditSecondNumber.text())
else:
b=0
sum=a+b
self.ui.labelResult.setText("Addition: " +str(sum))
def subtracttwonum(self):
if len(self.ui.lineEditFirstNumber.text())!=0:
a=int(self.ui.lineEditFirstNumber.text())
else:
a=0
if len(self.ui.lineEditSecondNumber.text())!=0:
b=int(self.ui.lineEditSecondNumber.text())
else:
b=0
diff=a-b
self.ui.labelResult.setText("Substraction: " +str(diff))
def multiplytwonum(self):
if len(self.ui.lineEditFirstNumber.text())!=0:
a=int(self.ui.lineEditFirstNumber.text())
else:
a=0
if len(self.ui.lineEditSecondNumber.text())!=0:
b=int(self.ui.lineEditSecondNumber.text())
else:
b=0
mult=a*b
self.ui.labelResult.setText("Multiplication: " +str(mult))
def dividetwonum(self):
if len(self.ui.lineEditFirstNumber.text())!=0:
a=int(self.ui.lineEditFirstNumber.text())
else:
a=0
if len(self.ui.lineEditSecondNumber.text())!=0:
b=int(self.ui.lineEditSecondNumber.text())
else:
b=0
division=a/b
self.ui.labelResult.setText("Division: " +str(round(division,2)))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callComboBox.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoComboBox import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.comboBoxAccountType.currentIndexChanged.connect(self.dispAccountType)
self.show()
def dispAccountType(self):
self.ui.labelAccountType.setText("You have selected "+self.ui.comboBoxAccountType.itemText(self.ui.comboBoxAccountType.currentIndex()))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callFontComboBox.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoFontComboBox import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
myFont=QtGui.QFont(self.ui.fontComboBox.itemText(self.ui.fontComboBox.currentIndex()),15)
self.ui.textEdit.setFont(myFont)
self.ui.fontComboBox.currentFontChanged.connect(self.changeFont)
self.show()
def changeFont(self):
myFont=QtGui.QFont(self.ui.fontComboBox.itemText(self.ui.fontComboBox.currentIndex()),15)
self.ui.textEdit.setFont(myFont)
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callListWidget1.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoListWidget1 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.listWidgetDiagnosis.itemClicked.connect(self.dispSelectedTest)
self.show()
def dispSelectedTest(self):
self.ui.labelTest.setText("You have selected "+self.ui.listWidgetDiagnosis.currentItem().text())
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callListWidget2.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoListWidget2 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.listWidgetDiagnosis.itemSelectionChanged.connect(self.dispSelectedTest)
self.show()
def dispSelectedTest(self):
self.ui.listWidgetSelectedTests.clear()
items = self.ui.listWidgetDiagnosis.selectedItems()
x=[]
for i in list(items):
self.ui.listWidgetSelectedTests.addItem(i.text())
x.append(str(i.text()))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callListWidget3.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoListWidget3 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.pushButtonAdd.clicked.connect(self.addlist)
self.show()
def addlist(self):
self.ui.listWidgetSelectedItems.addItem(self.ui.lineEditFoodItem.text())
self.ui.lineEditFoodItem.setText('')
self.ui.lineEditFoodItem.setFocus()
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callListWidgetOp.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication, QInputDialog, QListWidgetItem
from demoListWidgetOp import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.listWidget.addItem('Ice Cream')
self.ui.listWidget.addItem('Soda')
self.ui.listWidget.addItem('Coffee')
self.ui.listWidget.addItem('Chocolate')
self.ui.pushButtonAdd.clicked.connect(self.addlist)
self.ui.pushButtonEdit.clicked.connect(self.editlist)
self.ui.pushButtonDelete.clicked.connect(self.delitem)
self.ui.pushButtonDeleteAll.clicked.connect(self.delallitems)
self.show()
def addlist(self):
self.ui.listWidget.addItem(self.ui.lineEdit.text())
self.ui.lineEdit.setText('')
self.ui.lineEdit.setFocus()
def editlist(self):
row=self.ui.listWidget.currentRow()
newtext, ok=QInputDialog.getText(self, "Enter new text", "Enter new text")
if ok and (len(newtext) !=0):
self.ui.listWidget.takeItem(self.ui.listWidget.currentRow())
self.ui.listWidget.insertItem(row,QListWidgetItem(newtext))
def delitem(self):
self.ui.listWidget.takeItem(self.ui.listWidget.currentRow())
def delallitems(self):
self.ui.listWidget.clear()
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callProgressBar.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoProgressBar import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.pushButtonStart.clicked.connect(self.updateBar)
self.show()
def updateBar(self):
x = 0
while x < 100:
x += 0.0001
self.ui.progressBar.setValue(x)
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/callScrollBar.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoScrollBar import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.horizontalScrollBarSugarLevel.valueChanged.connect(self.scrollhorizontal)
self.ui.verticalScrollBarPulseRate.valueChanged.connect(self.scrollvertical)
self.ui.horizontalSliderBloodPressure.valueChanged.connect(self.sliderhorizontal)
self.ui.verticalSliderCholestrolLevel.valueChanged.connect(self.slidervertical)
self.show()
def scrollhorizontal(self,value):
self.ui.lineEditResult.setText("Sugar Level : "+str(value))
def scrollvertical(self, value):
self.ui.lineEditResult.setText("Pulse Rate : "+str(value))
def sliderhorizontal(self, value):
self.ui.lineEditResult.setText("Blood Pressure : "+str(value))
def slidervertical(self, value):
self.ui.lineEditResult.setText("Cholestrol Level : "+str(value))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/calldemoSignalSlot1.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoSignalSlot1 import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.show()
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/calldemoSpinner.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoSpinBox import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.spinBoxBookQty.editingFinished.connect(self.result1)
self.ui.doubleSpinBoxSugarWeight.editingFinished.connect(self.result2)
self.show()
def result1(self):
if len(self.ui.lineEditBookPrice.text())!=0:
bookPrice=int(self.ui.lineEditBookPrice.text())
else:
bookPrice=0
totalBookAmount=self.ui.spinBoxBookQty.value() * bookPrice
self.ui.lineEditBookAmount.setText(str(totalBookAmount))
def result2(self):
if len(self.ui.lineEditSugarPrice.text())!=0:
sugarPrice=float(self.ui.lineEditSugarPrice.text())
else:
sugarPrice=0
totalSugarAmount=self.ui.doubleSpinBoxSugarWeight.value() * sugarPrice
self.ui.lineEditSugarAmount.setText(str(round(totalSugarAmount,2)))
totalBookAmount=int(self.ui.lineEditBookAmount.text())
totalAmount=totalBookAmount+totalSugarAmount
self.ui.labelTotalAmount.setText(str(round(totalAmount,2)))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoCalculator.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoCalculator.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(427, 269)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(10, 30, 161, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(10, 80, 151, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEditFirstNumber = QtWidgets.QLineEdit(Dialog)
self.lineEditFirstNumber.setGeometry(QtCore.QRect(180, 30, 181, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditFirstNumber.setFont(font)
self.lineEditFirstNumber.setObjectName("lineEditFirstNumber")
self.lineEditSecondNumber = QtWidgets.QLineEdit(Dialog)
self.lineEditSecondNumber.setGeometry(QtCore.QRect(180, 80, 181, 21))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditSecondNumber.setFont(font)
self.lineEditSecondNumber.setObjectName("lineEditSecondNumber")
self.pushButtonPlus = QtWidgets.QPushButton(Dialog)
self.pushButtonPlus.setGeometry(QtCore.QRect(20, 150, 71, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonPlus.setFont(font)
self.pushButtonPlus.setObjectName("pushButtonPlus")
self.pushButtonSubtract = QtWidgets.QPushButton(Dialog)
self.pushButtonSubtract.setGeometry(QtCore.QRect(120, 150, 75, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonSubtract.setFont(font)
self.pushButtonSubtract.setObjectName("pushButtonSubtract")
self.pushButtonMultiply = QtWidgets.QPushButton(Dialog)
self.pushButtonMultiply.setGeometry(QtCore.QRect(220, 150, 81, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonMultiply.setFont(font)
self.pushButtonMultiply.setObjectName("pushButtonMultiply")
self.pushButtonDivide = QtWidgets.QPushButton(Dialog)
self.pushButtonDivide.setGeometry(QtCore.QRect(330, 150, 75, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonDivide.setFont(font)
self.pushButtonDivide.setObjectName("pushButtonDivide")
self.labelResult = QtWidgets.QLabel(Dialog)
self.labelResult.setGeometry(QtCore.QRect(30, 210, 351, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.labelResult.setFont(font)
self.labelResult.setText("")
self.labelResult.setObjectName("labelResult")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Enter first number"))
self.label_2.setText(_translate("Dialog", "Enter second number"))
self.pushButtonPlus.setText(_translate("Dialog", "+"))
self.pushButtonSubtract.setText(_translate("Dialog", "-"))
self.pushButtonMultiply.setText(_translate("Dialog", "X"))
self.pushButtonDivide.setText(_translate("Dialog", "/"))
================================================
FILE: Chapter02/demoCalculator.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>269</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>161</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Enter first number</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>151</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Enter second number</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditFirstNumber">
<property name="geometry">
<rect>
<x>180</x>
<y>30</y>
<width>181</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lineEditSecondNumber">
<property name="geometry">
<rect>
<x>180</x>
<y>80</y>
<width>181</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="pushButtonPlus">
<property name="geometry">
<rect>
<x>20</x>
<y>150</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonSubtract">
<property name="geometry">
<rect>
<x>120</x>
<y>150</y>
<width>75</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonMultiply">
<property name="geometry">
<rect>
<x>220</x>
<y>150</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonDivide">
<property name="geometry">
<rect>
<x>330</x>
<y>150</y>
<width>75</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>/</string>
</property>
</widget>
<widget class="QLabel" name="labelResult">
<property name="geometry">
<rect>
<x>30</x>
<y>210</y>
<width>351</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoComboBox.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoComboBox.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(674, 200)
self.comboBoxAccountType = QtWidgets.QComboBox(Dialog)
self.comboBoxAccountType.setGeometry(QtCore.QRect(260, 40, 361, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.comboBoxAccountType.setFont(font)
self.comboBoxAccountType.setObjectName("comboBoxAccountType")
self.comboBoxAccountType.addItem("")
self.comboBoxAccountType.addItem("")
self.comboBoxAccountType.addItem("")
self.comboBoxAccountType.addItem("")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 40, 231, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.labelAccountType = QtWidgets.QLabel(Dialog)
self.labelAccountType.setGeometry(QtCore.QRect(40, 110, 581, 41))
font = QtGui.QFont()
font.setPointSize(14)
self.labelAccountType.setFont(font)
self.labelAccountType.setText("")
self.labelAccountType.setObjectName("labelAccountType")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.comboBoxAccountType.setItemText(0, _translate("Dialog", "Saving Account"))
self.comboBoxAccountType.setItemText(1, _translate("Dialog", "Current Account"))
self.comboBoxAccountType.setItemText(2, _translate("Dialog", "Recurring Deposit Account"))
self.comboBoxAccountType.setItemText(3, _translate("Dialog", "Fixed Deposit Account"))
self.label.setText(_translate("Dialog", "Select your account type"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoComboBox.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>674</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QComboBox" name="comboBoxAccountType">
<property name="geometry">
<rect>
<x>260</x>
<y>40</y>
<width>361</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<item>
<property name="text">
<string>Saving Account</string>
</property>
</item>
<item>
<property name="text">
<string>Current Account</string>
</property>
</item>
<item>
<property name="text">
<string>Recurring Deposit Account</string>
</property>
</item>
<item>
<property name="text">
<string>Fixed Deposit Account</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>231</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Select your account type</string>
</property>
</widget>
<widget class="QLabel" name="labelAccountType">
<property name="geometry">
<rect>
<x>40</x>
<y>110</y>
<width>581</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoFontComboBox.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoFontComboBox.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(560, 228)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 20, 231, 41))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.labelTextLine = QtWidgets.QLabel(Dialog)
self.labelTextLine.setGeometry(QtCore.QRect(20, 60, 161, 41))
font = QtGui.QFont()
font.setPointSize(14)
self.labelTextLine.setFont(font)
self.labelTextLine.setObjectName("labelTextLine")
self.fontComboBox = QtWidgets.QFontComboBox(Dialog)
self.fontComboBox.setGeometry(QtCore.QRect(200, 20, 321, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.fontComboBox.setFont(font)
self.fontComboBox.setObjectName("fontComboBox")
self.textEdit = QtWidgets.QTextEdit(Dialog)
self.textEdit.setGeometry(QtCore.QRect(200, 70, 321, 121))
self.textEdit.setObjectName("textEdit")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Select desired font"))
self.labelTextLine.setText(_translate("Dialog", "Type some text"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoFontComboBox.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>552</width>
<height>228</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>231</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Select desired font</string>
</property>
</widget>
<widget class="QLabel" name="labelTextLine">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>161</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Type some text</string>
</property>
</widget>
<widget class="QFontComboBox" name="fontComboBox">
<property name="geometry">
<rect>
<x>200</x>
<y>20</y>
<width>321</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
</widget>
<widget class="QTextEdit" name="textEdit">
<property name="geometry">
<rect>
<x>200</x>
<y>70</y>
<width>321</width>
<height>121</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoListWidget1.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoListWidget1.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(686, 287)
self.listWidgetDiagnosis = QtWidgets.QListWidget(Dialog)
self.listWidgetDiagnosis.setGeometry(QtCore.QRect(280, 20, 351, 171))
font = QtGui.QFont()
font.setPointSize(14)
self.listWidgetDiagnosis.setFont(font)
self.listWidgetDiagnosis.setObjectName("listWidgetDiagnosis")
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
self.labelTest = QtWidgets.QLabel(Dialog)
self.labelTest.setGeometry(QtCore.QRect(40, 230, 621, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.labelTest.setFont(font)
self.labelTest.setText("")
self.labelTest.setObjectName("labelTest")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(30, 10, 241, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
__sortingEnabled = self.listWidgetDiagnosis.isSortingEnabled()
self.listWidgetDiagnosis.setSortingEnabled(False)
item = self.listWidgetDiagnosis.item(0)
item.setText(_translate("Dialog", "Urine Analaysis $5"))
item = self.listWidgetDiagnosis.item(1)
item.setText(_translate("Dialog", "Chest X Ray 100$"))
item = self.listWidgetDiagnosis.item(2)
item.setText(_translate("Dialog", "Sugar Level test $3"))
item = self.listWidgetDiagnosis.item(3)
item.setText(_translate("Dialog", "Hemoglobin test $7"))
item = self.listWidgetDiagnosis.item(4)
item.setText(_translate("Dialog", "Thyroid Stimulating Harmone test $10"))
self.listWidgetDiagnosis.setSortingEnabled(__sortingEnabled)
self.label.setText(_translate("Dialog", "Choose the Diagnosis Tests"))
================================================
FILE: Chapter02/demoListWidget1.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>686</width>
<height>287</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QListWidget" name="listWidgetDiagnosis">
<property name="geometry">
<rect>
<x>280</x>
<y>20</y>
<width>351</width>
<height>171</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<item>
<property name="text">
<string>Urine Analaysis $5</string>
</property>
</item>
<item>
<property name="text">
<string>Chest X Ray 100$</string>
</property>
</item>
<item>
<property name="text">
<string>Sugar Level test $3</string>
</property>
</item>
<item>
<property name="text">
<string>Hemoglobin test $7</string>
</property>
</item>
<item>
<property name="text">
<string>Thyroid Stimulating Harmone test $10</string>
</property>
</item>
</widget>
<widget class="QLabel" name="labelTest">
<property name="geometry">
<rect>
<x>40</x>
<y>230</y>
<width>621</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>30</x>
<y>10</y>
<width>241</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Choose the Diagnosis Tests</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoListWidget2.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoListWidget2.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(729, 412)
self.listWidgetDiagnosis = QtWidgets.QListWidget(Dialog)
self.listWidgetDiagnosis.setGeometry(QtCore.QRect(200, 20, 351, 171))
font = QtGui.QFont()
font.setPointSize(14)
self.listWidgetDiagnosis.setFont(font)
self.listWidgetDiagnosis.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
self.listWidgetDiagnosis.setObjectName("listWidgetDiagnosis")
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidgetDiagnosis.addItem(item)
self.labelTest = QtWidgets.QLabel(Dialog)
self.labelTest.setGeometry(QtCore.QRect(20, 230, 171, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.labelTest.setFont(font)
self.labelTest.setObjectName("labelTest")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(30, 10, 151, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.listWidgetSelectedTests = QtWidgets.QListWidget(Dialog)
self.listWidgetSelectedTests.setGeometry(QtCore.QRect(200, 220, 351, 192))
font = QtGui.QFont()
font.setPointSize(14)
self.listWidgetSelectedTests.setFont(font)
self.listWidgetSelectedTests.setObjectName("listWidgetSelectedTests")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
__sortingEnabled = self.listWidgetDiagnosis.isSortingEnabled()
self.listWidgetDiagnosis.setSortingEnabled(False)
item = self.listWidgetDiagnosis.item(0)
item.setText(_translate("Dialog", "Urine Analaysis $5"))
item = self.listWidgetDiagnosis.item(1)
item.setText(_translate("Dialog", "Chest X Ray 100$"))
item = self.listWidgetDiagnosis.item(2)
item.setText(_translate("Dialog", "Sugar Level test $3"))
item = self.listWidgetDiagnosis.item(3)
item.setText(_translate("Dialog", "Hemoglobin test $7"))
item = self.listWidgetDiagnosis.item(4)
item.setText(_translate("Dialog", "Thyroid Stimulating Harmone test $10"))
self.listWidgetDiagnosis.setSortingEnabled(__sortingEnabled)
self.labelTest.setText(_translate("Dialog", "Selected tests are"))
self.label.setText(_translate("Dialog", "Diagnosis Tests"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoListWidget2.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>729</width>
<height>412</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QListWidget" name="listWidgetDiagnosis">
<property name="geometry">
<rect>
<x>200</x>
<y>20</y>
<width>351</width>
<height>171</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<item>
<property name="text">
<string>Urine Analaysis $5</string>
</property>
</item>
<item>
<property name="text">
<string>Chest X Ray 100$</string>
</property>
</item>
<item>
<property name="text">
<string>Sugar Level test $3</string>
</property>
</item>
<item>
<property name="text">
<string>Hemoglobin test $7</string>
</property>
</item>
<item>
<property name="text">
<string>Thyroid Stimulating Harmone test $10</string>
</property>
</item>
</widget>
<widget class="QLabel" name="labelTest">
<property name="geometry">
<rect>
<x>20</x>
<y>230</y>
<width>171</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Selected tests are</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>30</x>
<y>10</y>
<width>151</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Diagnosis Tests</string>
</property>
</widget>
<widget class="QListWidget" name="listWidgetSelectedTests">
<property name="geometry">
<rect>
<x>200</x>
<y>220</y>
<width>351</width>
<height>192</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoListWidget3.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoListWidget3.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(734, 270)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 20, 191, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineEditFoodItem = QtWidgets.QLineEdit(Dialog)
self.lineEditFoodItem.setGeometry(QtCore.QRect(210, 20, 201, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditFoodItem.setFont(font)
self.lineEditFoodItem.setObjectName("lineEditFoodItem")
self.pushButtonAdd = QtWidgets.QPushButton(Dialog)
self.pushButtonAdd.setGeometry(QtCore.QRect(110, 72, 111, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonAdd.setFont(font)
self.pushButtonAdd.setObjectName("pushButtonAdd")
self.listWidgetSelectedItems = QtWidgets.QListWidget(Dialog)
self.listWidgetSelectedItems.setGeometry(QtCore.QRect(430, 20, 256, 221))
font = QtGui.QFont()
font.setPointSize(12)
self.listWidgetSelectedItems.setFont(font)
self.listWidgetSelectedItems.setObjectName("listWidgetSelectedItems")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Your favourite food item"))
self.pushButtonAdd.setText(_translate("Dialog", "Add to List"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoListWidget3.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>734</width>
<height>270</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>191</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Your favourite food item</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditFoodItem">
<property name="geometry">
<rect>
<x>210</x>
<y>20</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="pushButtonAdd">
<property name="geometry">
<rect>
<x>110</x>
<y>72</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Add to List</string>
</property>
</widget>
<widget class="QListWidget" name="listWidgetSelectedItems">
<property name="geometry">
<rect>
<x>430</x>
<y>20</y>
<width>256</width>
<height>221</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoListWidgetOp.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoListWidgetOp.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(691, 260)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(16, 30, 121, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(130, 30, 191, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEdit.setFont(font)
self.lineEdit.setObjectName("lineEdit")
self.pushButtonAdd = QtWidgets.QPushButton(Dialog)
self.pushButtonAdd.setGeometry(QtCore.QRect(180, 80, 75, 23))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonAdd.setFont(font)
self.pushButtonAdd.setObjectName("pushButtonAdd")
self.listWidget = QtWidgets.QListWidget(Dialog)
self.listWidget.setGeometry(QtCore.QRect(380, 30, 256, 192))
font = QtGui.QFont()
font.setPointSize(12)
self.listWidget.setFont(font)
self.listWidget.setObjectName("listWidget")
self.pushButtonDelete = QtWidgets.QPushButton(Dialog)
self.pushButtonDelete.setGeometry(QtCore.QRect(470, 230, 75, 23))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonDelete.setFont(font)
self.pushButtonDelete.setObjectName("pushButtonDelete")
self.pushButtonDeleteAll = QtWidgets.QPushButton(Dialog)
self.pushButtonDeleteAll.setGeometry(QtCore.QRect(560, 230, 75, 23))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonDeleteAll.setFont(font)
self.pushButtonDeleteAll.setObjectName("pushButtonDeleteAll")
self.pushButtonEdit = QtWidgets.QPushButton(Dialog)
self.pushButtonEdit.setGeometry(QtCore.QRect(380, 230, 75, 23))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonEdit.setFont(font)
self.pushButtonEdit.setObjectName("pushButtonEdit")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Enter an item"))
self.pushButtonAdd.setText(_translate("Dialog", "Add"))
self.pushButtonDelete.setText(_translate("Dialog", "Delete"))
self.pushButtonDeleteAll.setText(_translate("Dialog", "Delete All"))
self.pushButtonEdit.setText(_translate("Dialog", "Edit"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoListWidgetOp.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>691</width>
<height>260</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>16</x>
<y>30</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Enter an item</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>130</x>
<y>30</y>
<width>191</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="pushButtonAdd">
<property name="geometry">
<rect>
<x>180</x>
<y>80</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
<widget class="QListWidget" name="listWidget">
<property name="geometry">
<rect>
<x>380</x>
<y>30</y>
<width>256</width>
<height>192</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="pushButtonDelete">
<property name="geometry">
<rect>
<x>470</x>
<y>230</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonDeleteAll">
<property name="geometry">
<rect>
<x>560</x>
<y>230</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Delete All</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonEdit">
<property name="geometry">
<rect>
<x>380</x>
<y>230</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoProgressBar.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoProgressBar.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(350, 153)
self.progressBar = QtWidgets.QProgressBar(Dialog)
self.progressBar.setGeometry(QtCore.QRect(40, 60, 281, 23))
font = QtGui.QFont()
font.setPointSize(12)
self.progressBar.setFont(font)
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(80, 20, 181, 21))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.pushButtonStart = QtWidgets.QPushButton(Dialog)
self.pushButtonStart.setGeometry(QtCore.QRect(80, 110, 151, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonStart.setFont(font)
self.pushButtonStart.setObjectName("pushButtonStart")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Downloading the file"))
self.pushButtonStart.setText(_translate("Dialog", "Start Downloading"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoProgressBar.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>153</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>40</x>
<y>60</y>
<width>281</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>80</x>
<y>20</y>
<width>181</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Downloading the file</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonStart">
<property name="geometry">
<rect>
<x>80</x>
<y>110</y>
<width>151</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Start Downloading</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoScrollBar.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoScrollBar.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(538, 431)
self.horizontalScrollBarSugarLevel = QtWidgets.QScrollBar(Dialog)
self.horizontalScrollBarSugarLevel.setGeometry(QtCore.QRect(200, 30, 301, 21))
font = QtGui.QFont()
font.setPointSize(12)
self.horizontalScrollBarSugarLevel.setFont(font)
self.horizontalScrollBarSugarLevel.setOrientation(QtCore.Qt.Horizontal)
self.horizontalScrollBarSugarLevel.setObjectName("horizontalScrollBarSugarLevel")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(40, 30, 111, 21))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(40, 110, 141, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.verticalScrollBarPulseRate = QtWidgets.QScrollBar(Dialog)
self.verticalScrollBarPulseRate.setGeometry(QtCore.QRect(160, 110, 16, 160))
font = QtGui.QFont()
font.setPointSize(12)
self.verticalScrollBarPulseRate.setFont(font)
self.verticalScrollBarPulseRate.setOrientation(QtCore.Qt.Vertical)
self.verticalScrollBarPulseRate.setObjectName("verticalScrollBarPulseRate")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(40, 70, 151, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.horizontalSliderBloodPressure = QtWidgets.QSlider(Dialog)
self.horizontalSliderBloodPressure.setGeometry(QtCore.QRect(210, 70, 291, 22))
font = QtGui.QFont()
font.setPointSize(12)
self.horizontalSliderBloodPressure.setFont(font)
self.horizontalSliderBloodPressure.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSliderBloodPressure.setObjectName("horizontalSliderBloodPressure")
self.label_4 = QtWidgets.QLabel(Dialog)
self.label_4.setGeometry(QtCore.QRect(240, 110, 131, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.verticalSliderCholestrolLevel = QtWidgets.QSlider(Dialog)
self.verticalSliderCholestrolLevel.setGeometry(QtCore.QRect(410, 109, 22, 171))
font = QtGui.QFont()
font.setPointSize(12)
self.verticalSliderCholestrolLevel.setFont(font)
self.verticalSliderCholestrolLevel.setOrientation(QtCore.Qt.Vertical)
self.verticalSliderCholestrolLevel.setObjectName("verticalSliderCholestrolLevel")
self.lineEditResult = QtWidgets.QLineEdit(Dialog)
self.lineEditResult.setGeometry(QtCore.QRect(60, 340, 391, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditResult.setFont(font)
self.lineEditResult.setObjectName("lineEditResult")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Sugar Level"))
self.label_2.setText(_translate("Dialog", "Pulse rate"))
self.label_3.setText(_translate("Dialog", "Blood Pressure"))
self.label_4.setText(_translate("Dialog", "Cholestrol Level"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoScrollBar.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<height>431</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QScrollBar" name="horizontalScrollBarSugarLevel">
<property name="geometry">
<rect>
<x>200</x>
<y>30</y>
<width>301</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Sugar Level</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>110</y>
<width>141</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Pulse rate</string>
</property>
</widget>
<widget class="QScrollBar" name="verticalScrollBarPulseRate">
<property name="geometry">
<rect>
<x>160</x>
<y>110</y>
<width>16</width>
<height>160</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>40</x>
<y>70</y>
<width>151</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Blood Pressure</string>
</property>
</widget>
<widget class="QSlider" name="horizontalSliderBloodPressure">
<property name="geometry">
<rect>
<x>210</x>
<y>70</y>
<width>291</width>
<height>22</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>240</x>
<y>110</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Cholestrol Level</string>
</property>
</widget>
<widget class="QSlider" name="verticalSliderCholestrolLevel">
<property name="geometry">
<rect>
<x>410</x>
<y>109</y>
<width>22</width>
<height>171</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLineEdit" name="lineEditResult">
<property name="geometry">
<rect>
<x>60</x>
<y>340</y>
<width>391</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter02/demoSignalSlot1.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoSignalSlot1.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(348, 453)
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(90, 50, 181, 20))
self.lineEdit.setObjectName("lineEdit")
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(140, 160, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Dialog)
self.pushButton_2.setGeometry(QtCore.QRect(140, 260, 75, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.lineEdit_2 = QtWidgets.QLineEdit(Dialog)
self.lineEdit_2.setGeometry(QtCore.QRect(90, 390, 181, 20))
self.lineEdit_2.setObjectName("lineEdit_2")
self.retranslateUi(Dialog)
self.pushButton.pressed.connect(self.lineEdit.selectAll)
self.pushButton_2.clicked.connect(self.lineEdit_2.paste)
self.pushButton.released.connect(self.lineEdit.copy)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton.setText(_translate("Dialog", "Copy"))
self.pushButton_2.setText(_translate("Dialog", "Paste"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter02/demoSignalSlot1.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>348</width>
<height>453</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>90</x>
<y>50</y>
<width>181</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>140</x>
<y>160</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Copy</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>140</x>
<y>260</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Paste</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>90</x>
<y>390</y>
<width>181</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>pressed()</signal>
<receiver>lineEdit</receiver>
<slot>selectAll()</slot>
<hints>
<hint type="sourcelabel">
<x>175</x>
<y>181</y>
</hint>
<hint type="destinationlabel">
<x>183</x>
<y>67</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton_2</sender>
<signal>clicked()</signal>
<receiver>lineEdit_2</receiver>
<slot>paste()</slot>
<hints>
<hint type="sourcelabel">
<x>174</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>172</x>
<y>396</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton</sender>
<signal>released()</signal>
<receiver>lineEdit</receiver>
<slot>copy()</slot>
<hints>
<hint type="sourcelabel">
<x>150</x>
<y>169</y>
</hint>
<hint type="destinationlabel">
<x>153</x>
<y>58</y>
</hint>
</hints>
</connection>
</connections>
</ui>
================================================
FILE: Chapter02/demoSpinBox.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoSpinBox.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(580, 162)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(16, 30, 81, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineEditBookPrice = QtWidgets.QLineEdit(Dialog)
self.lineEditBookPrice.setGeometry(QtCore.QRect(120, 30, 113, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditBookPrice.setFont(font)
self.lineEditBookPrice.setObjectName("lineEditBookPrice")
self.spinBoxBookQty = QtWidgets.QSpinBox(Dialog)
self.spinBoxBookQty.setGeometry(QtCore.QRect(290, 30, 42, 22))
font = QtGui.QFont()
font.setPointSize(12)
self.spinBoxBookQty.setFont(font)
self.spinBoxBookQty.setObjectName("spinBoxBookQty")
self.lineEditBookAmount = QtWidgets.QLineEdit(Dialog)
self.lineEditBookAmount.setGeometry(QtCore.QRect(390, 30, 113, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditBookAmount.setFont(font)
self.lineEditBookAmount.setObjectName("lineEditBookAmount")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(10, 70, 81, 21))
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEditSugarPrice = QtWidgets.QLineEdit(Dialog)
self.lineEditSugarPrice.setGeometry(QtCore.QRect(120, 70, 113, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditSugarPrice.setFont(font)
self.lineEditSugarPrice.setObjectName("lineEditSugarPrice")
self.doubleSpinBoxSugarWeight = QtWidgets.QDoubleSpinBox(Dialog)
self.doubleSpinBoxSugarWeight.setGeometry(QtCore.QRect(290, 70, 62, 22))
font = QtGui.QFont()
font.setPointSize(12)
self.doubleSpinBoxSugarWeight.setFont(font)
self.doubleSpinBoxSugarWeight.setObjectName("doubleSpinBoxSugarWeight")
self.lineEditSugarAmount = QtWidgets.QLineEdit(Dialog)
self.lineEditSugarAmount.setGeometry(QtCore.QRect(390, 70, 113, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditSugarAmount.setFont(font)
self.lineEditSugarAmount.setObjectName("lineEditSugarAmount")
self.labelTotalAmount = QtWidgets.QLabel(Dialog)
self.labelTotalAmount.setGeometry(QtCore.QRect(396, 120, 121, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.labelTotalAmount.setFont(font)
self.labelTotalAmount.setObjectName("labelTotalAmount")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Book Price"))
self.label_2.setText(_translate("Dialog", "Sugar Price"))
self.labelTotalAmount.setText(_translate("Dialog", "TextLabel"))
================================================
FILE: Chapter02/demoSpinBox.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>580</width>
<height>162</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>16</x>
<y>30</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Book Price</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditBookPrice">
<property name="geometry">
<rect>
<x>120</x>
<y>30</y>
<width>113</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QSpinBox" name="spinBoxBookQty">
<property name="geometry">
<rect>
<x>290</x>
<y>30</y>
<width>42</width>
<height>22</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lineEditBookAmount">
<property name="geometry">
<rect>
<x>390</x>
<y>30</y>
<width>113</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>81</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Sugar Price</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditSugarPrice">
<property name="geometry">
<rect>
<x>120</x>
<y>70</y>
<width>113</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSugarWeight">
<property name="geometry">
<rect>
<x>290</x>
<y>70</y>
<width>62</width>
<height>22</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lineEditSugarAmount">
<property name="geometry">
<rect>
<x>390</x>
<y>70</y>
<width>113</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="labelTotalAmount">
<property name="geometry">
<rect>
<x>396</x>
<y>120</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter03/DemoTableWidget.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>289</width>
<height>236</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>221</width>
<height>191</height>
</rect>
</property>
<property name="rowCount">
<number>4</number>
</property>
<property name="columnCount">
<number>2</number>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>40</number>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<row/>
<row/>
<row/>
<row/>
<column/>
<column/>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter03/callCalendar.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoCalendar import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.calendarWidget.selectionChanged.connect(self.dispdate)
self.show()
def dispdate(self):
self.ui.dateEdit.setDisplayFormat('MMM d yyyy')
self.ui.dateEdit.setDate(self.ui.calendarWidget.selectedDate())
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter03/callLCD.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoLCD import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
timer = QtCore.QTimer(self)
timer.timeout.connect(self.showlcd)
timer.start(1000)
self.showlcd()
def showlcd(self):
time = QtCore.QTime.currentTime()
text = time.toString('hh:mm')
self.ui.lcdNumber.display(text)
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter03/callTableWidget.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication,QTableWidgetItem
from DemoTableWidget import *
class MyForm(QDialog):
def __init__(self,data):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.data=data
self.addcontent()
def addcontent(self):
row=0
for tup in self.data:
col=0
for item in tup:
oneitem=QTableWidgetItem(item)
self.ui.tableWidget.setItem(row, col, oneitem)
col+=1
row+=1
data=[]
data.append(('Suite', '40$'))
data.append(('Super Luxury', '30$'))
data.append(('Super Deluxe', '20$'))
data.append(('Ordinary', '10$'))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm(data)
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter03/computeRoomRent.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from reservehotel import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.roomtypes=['Suite', 'Super Luxury', 'Super Deluxe', 'Ordinary']
self.addcontent()
self.ui.pushButton.clicked.connect(self.computeRoomRent)
self.show()
def addcontent(self):
for i in self.roomtypes:
self.ui.comboBox.addItem(i)
def computeRoomRent(self):
dateselected=self.ui.calendarWidget.selectedDate()
dateinstring=str(dateselected.toPyDate())
noOfDays=self.ui.spinBox.value()
chosenRoomType=self.ui.comboBox.itemText(self.ui.comboBox.currentIndex())
self.ui.Enteredinfo.setText('Date of reservation: '+dateinstring+ ', Number of days: '+ str(noOfDays) + ' \nand Room type selected: '+ chosenRoomType)
roomRent=0
if chosenRoomType=="Suite":
roomRent=40
if chosenRoomType=="Super Luxury":
roomRent=30
if chosenRoomType=="Super Deluxe":
roomRent=20
if chosenRoomType=="Ordinary":
roomRent=10
total=roomRent*noOfDays
self.ui.RoomRentinfo.setText('Room Rent for single day for '+ chosenRoomType +' type is '+ str(roomRent)+ '$. \nTotal room rent is '+ str(total)+ '$')
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter03/demoCalendar.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoCalendar.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(384, 300)
self.calendarWidget = QtWidgets.QCalendarWidget(Dialog)
self.calendarWidget.setGeometry(QtCore.QRect(40, 30, 312, 183))
self.calendarWidget.setObjectName("calendarWidget")
self.dateEdit = QtWidgets.QDateEdit(Dialog)
self.dateEdit.setGeometry(QtCore.QRect(120, 250, 110, 22))
self.dateEdit.setObjectName("dateEdit")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter03/demoCalendar.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QCalendarWidget" name="calendarWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>312</width>
<height>183</height>
</rect>
</property>
</widget>
<widget class="QDateEdit" name="dateEdit">
<property name="geometry">
<rect>
<x>120</x>
<y>250</y>
<width>110</width>
<height>22</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter03/demoLCD.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoLCD.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(240, 135)
self.lcdNumber = QtWidgets.QLCDNumber(Dialog)
self.lcdNumber.setGeometry(QtCore.QRect(60, 40, 100, 40))
self.lcdNumber.setObjectName("lcdNumber")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter03/demoLCD.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>135</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLCDNumber" name="lcdNumber">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>100</width>
<height>40</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter03/demoTabWidget.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoTabWidget.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(574, 300)
self.tabWidget = QtWidgets.QTabWidget(Dialog)
self.tabWidget.setGeometry(QtCore.QRect(10, 10, 481, 271))
font = QtGui.QFont()
font.setPointSize(12)
self.tabWidget.setFont(font)
self.tabWidget.setObjectName("tabWidget")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.checkBox = QtWidgets.QCheckBox(self.tab)
self.checkBox.setGeometry(QtCore.QRect(30, 30, 191, 17))
self.checkBox.setObjectName("checkBox")
self.checkBox_2 = QtWidgets.QCheckBox(self.tab)
self.checkBox_2.setGeometry(QtCore.QRect(30, 70, 141, 17))
self.checkBox_2.setObjectName("checkBox_2")
self.checkBox_3 = QtWidgets.QCheckBox(self.tab)
self.checkBox_3.setGeometry(QtCore.QRect(30, 110, 161, 17))
self.checkBox_3.setObjectName("checkBox_3")
self.checkBox_4 = QtWidgets.QCheckBox(self.tab)
self.checkBox_4.setGeometry(QtCore.QRect(30, 150, 171, 17))
self.checkBox_4.setObjectName("checkBox_4")
self.pushButton = QtWidgets.QPushButton(self.tab)
self.pushButton.setGeometry(QtCore.QRect(40, 190, 141, 23))
self.pushButton.setObjectName("pushButton")
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.radioButton = QtWidgets.QRadioButton(self.tab_2)
self.radioButton.setGeometry(QtCore.QRect(40, 30, 131, 17))
self.radioButton.setObjectName("radioButton")
self.radioButton_2 = QtWidgets.QRadioButton(self.tab_2)
self.radioButton_2.setGeometry(QtCore.QRect(40, 80, 111, 17))
self.radioButton_2.setObjectName("radioButton_2")
self.radioButton_3 = QtWidgets.QRadioButton(self.tab_2)
self.radioButton_3.setGeometry(QtCore.QRect(40, 130, 121, 21))
self.radioButton_3.setObjectName("radioButton_3")
self.radioButton_4 = QtWidgets.QRadioButton(self.tab_2)
self.radioButton_4.setGeometry(QtCore.QRect(40, 180, 181, 21))
self.radioButton_4.setObjectName("radioButton_4")
self.tabWidget.addTab(self.tab_2, "")
self.tab_3 = QtWidgets.QWidget()
self.tab_3.setObjectName("tab_3")
self.lineEdit = QtWidgets.QLineEdit(self.tab_3)
self.lineEdit.setGeometry(QtCore.QRect(160, 10, 291, 20))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.tab_3)
self.lineEdit_2.setGeometry(QtCore.QRect(160, 50, 291, 20))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(self.tab_3)
self.lineEdit_3.setGeometry(QtCore.QRect(160, 90, 291, 20))
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_4 = QtWidgets.QLineEdit(self.tab_3)
self.lineEdit_4.setGeometry(QtCore.QRect(160, 130, 291, 20))
self.lineEdit_4.setObjectName("lineEdit_4")
self.lineEdit_5 = QtWidgets.QLineEdit(self.tab_3)
self.lineEdit_5.setGeometry(QtCore.QRect(160, 170, 291, 20))
self.lineEdit_5.setObjectName("lineEdit_5")
self.lineEdit_6 = QtWidgets.QLineEdit(self.tab_3)
self.lineEdit_6.setGeometry(QtCore.QRect(160, 210, 291, 20))
self.lineEdit_6.setObjectName("lineEdit_6")
self.label = QtWidgets.QLabel(self.tab_3)
self.label.setGeometry(QtCore.QRect(10, 10, 91, 16))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.tab_3)
self.label_2.setGeometry(QtCore.QRect(10, 50, 71, 16))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.tab_3)
self.label_3.setGeometry(QtCore.QRect(10, 90, 47, 13))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.tab_3)
self.label_4.setGeometry(QtCore.QRect(10, 130, 71, 21))
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.tab_3)
self.label_5.setGeometry(QtCore.QRect(10, 170, 71, 16))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.tab_3)
self.label_6.setGeometry(QtCore.QRect(10, 210, 121, 16))
self.label_6.setObjectName("label_6")
self.tabWidget.addTab(self.tab_3, "")
self.retranslateUi(Dialog)
self.tabWidget.setCurrentIndex(2)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.checkBox.setText(_translate("Dialog", "Cell Phone $150"))
self.checkBox_2.setText(_translate("Dialog", "Laptop $500"))
self.checkBox_3.setText(_translate("Dialog", "Camera $250"))
self.checkBox_4.setText(_translate("Dialog", "Shoes $200"))
self.pushButton.setText(_translate("Dialog", "Add to Cart"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Dialog", "Products Listing"))
self.radioButton.setText(_translate("Dialog", "Debit Card"))
self.radioButton_2.setText(_translate("Dialog", "Credit Card"))
self.radioButton_3.setText(_translate("Dialog", "Net Banking"))
self.radioButton_4.setText(_translate("Dialog", "Cash On Delivery"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Dialog", "Payment Method"))
self.label.setText(_translate("Dialog", "Address 1"))
self.label_2.setText(_translate("Dialog", "Address 2"))
self.label_3.setText(_translate("Dialog", "State"))
self.label_4.setText(_translate("Dialog", "Country"))
self.label_5.setText(_translate("Dialog", "Zip Code"))
self.label_6.setText(_translate("Dialog", "Contact Number"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("Dialog", "Delivery Address"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter03/reservehotel.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'reservehotel.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(553, 556)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(140, 10, 241, 20))
font = QtGui.QFont()
font.setPointSize(17)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(10, 60, 161, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(10, 250, 161, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.calendarWidget = QtWidgets.QCalendarWidget(Dialog)
self.calendarWidget.setGeometry(QtCore.QRect(210, 60, 312, 183))
font = QtGui.QFont()
font.setPointSize(12)
self.calendarWidget.setFont(font)
self.calendarWidget.setObjectName("calendarWidget")
self.spinBox = QtWidgets.QSpinBox(Dialog)
self.spinBox.setGeometry(QtCore.QRect(210, 260, 42, 22))
font = QtGui.QFont()
font.setPointSize(12)
self.spinBox.setFont(font)
self.spinBox.setObjectName("spinBox")
self.label_4 = QtWidgets.QLabel(Dialog)
self.label_4.setGeometry(QtCore.QRect(20, 300, 111, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.comboBox = QtWidgets.QComboBox(Dialog)
self.comboBox.setGeometry(QtCore.QRect(210, 300, 211, 22))
font = QtGui.QFont()
font.setPointSize(12)
self.comboBox.setFont(font)
self.comboBox.setObjectName("comboBox")
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(170, 350, 241, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.Enteredinfo = QtWidgets.QLabel(Dialog)
self.Enteredinfo.setGeometry(QtCore.QRect(20, 400, 501, 51))
font = QtGui.QFont()
font.setPointSize(12)
self.Enteredinfo.setFont(font)
self.Enteredinfo.setText("")
self.Enteredinfo.setObjectName("Enteredinfo")
self.RoomRentinfo = QtWidgets.QLabel(Dialog)
self.RoomRentinfo.setGeometry(QtCore.QRect(10, 480, 501, 51))
font = QtGui.QFont()
font.setPointSize(12)
self.RoomRentinfo.setFont(font)
self.RoomRentinfo.setText("")
self.RoomRentinfo.setObjectName("RoomRentinfo")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Hotel Room Reservation"))
self.label_2.setText(_translate("Dialog", "Date of Reservation"))
self.label_3.setText(_translate("Dialog", "Number of days"))
self.label_4.setText(_translate("Dialog", "Room type"))
self.pushButton.setText(_translate("Dialog", "Caclulate Room Rent"))
================================================
FILE: Chapter03/reservehotel.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>553</width>
<height>556</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>140</x>
<y>10</y>
<width>241</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>17</pointsize>
</font>
</property>
<property name="text">
<string>Hotel Room Reservation</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>161</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Date of Reservation</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>161</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Number of days</string>
</property>
</widget>
<widget class="QCalendarWidget" name="calendarWidget">
<property name="geometry">
<rect>
<x>210</x>
<y>60</y>
<width>312</width>
<height>183</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QSpinBox" name="spinBox">
<property name="geometry">
<rect>
<x>210</x>
<y>260</y>
<width>42</width>
<height>22</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>300</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Room type</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>210</x>
<y>300</y>
<width>211</width>
<height>22</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>170</x>
<y>350</y>
<width>241</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Caclulate Room Rent</string>
</property>
</widget>
<widget class="QLabel" name="Enteredinfo">
<property name="geometry">
<rect>
<x>20</x>
<y>400</y>
<width>501</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="RoomRentinfo">
<property name="geometry">
<rect>
<x>10</x>
<y>480</y>
<width>501</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter04/LineEditClass.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoLineEdit.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(379, 195)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(6, 40, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label.setFont(font)
self.label.setObjectName("label")
self.labelResponse = QtWidgets.QLabel(Dialog)
self.labelResponse.setGeometry(QtCore.QRect(40, 90, 271, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.labelResponse.setFont(font)
self.labelResponse.setObjectName("labelResponse")
self.lineEditName = QtWidgets.QLineEdit(Dialog)
self.lineEditName.setGeometry(QtCore.QRect(140, 40, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditName.setFont(font)
self.lineEditName.setObjectName("lineEditName")
self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
self.ButtonClickMe.setGeometry(QtCore.QRect(160, 130, 101, 23))
font = QtGui.QFont()
font.setPointSize(11)
self.ButtonClickMe.setFont(font)
self.ButtonClickMe.setObjectName("ButtonClickMe")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Enter your name"))
self.labelResponse.setText(_translate("Dialog", "TextLabel"))
self.ButtonClickMe.setText(_translate("Dialog", "Click"))
================================================
FILE: Chapter04/LineEditClass.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>379</width>
<height>195</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>6</x>
<y>40</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Enter your name</string>
</property>
</widget>
<widget class="QLabel" name="labelResponse">
<property name="geometry">
<rect>
<x>40</x>
<y>90</y>
<width>271</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>140</x>
<y>40</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="ButtonClickMe">
<property name="geometry">
<rect>
<x>160</x>
<y>130</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Click</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter04/callLineEditClass.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from LineEditClass import *
class Student:
name = ""
def __init__(self, name):
self.name = name
def printName(self):
return self.name
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
self.show()
def dispmessage(self):
studentObj=Student(self.ui.lineEditName.text())
self.ui.labelResponse.setText("Hello "+studentObj.printName())
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/callMultilevelInheritance.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoMultilevelInheritance import *
class Student:
name = ""
code = ""
def __init__(self, code, name):
self.code = code
self.name = name
def getCode(self):
return self.code
def getName(self):
return self.name
class Marks(Student):
historyMarks = 0
geographyMarks = 0
def __init__(self, code, name, historyMarks, geographyMarks):
Student.__init__(self,code,name)
self.historyMarks = historyMarks
self.geographyMarks = geographyMarks
def getHistoryMarks(self):
return self.historyMarks
def getGeographyMarks(self):
return self.geographyMarks
class Result(Marks):
totalMarks = 0
percentage = 0
def __init__(self, code, name, historyMarks, geographyMarks):
Marks.__init__(self, code, name, historyMarks, geographyMarks)
self.totalMarks = historyMarks + geographyMarks
self.percentage = (historyMarks + geographyMarks) / 200 * 100
def getTotalMarks(self):
return self.totalMarks
def getPercentage(self):
return self.percentage
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
self.show()
def dispmessage(self):
resultObj=Result(self.ui.lineEditCode.text(), self.ui.lineEditName.text(), int(self.ui.lineEditHistoryMarks.text()), int(self.ui.lineEditGeographyMarks.text()))
self.ui.lineEditTotal.setText(str(resultObj.getTotalMarks()))
self.ui.lineEditPercentage.setText(str(resultObj.getPercentage()))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/callMultipleInheritance.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoMultipleInheritance import *
class Student:
name = ""
code = ""
def __init__(self, code, name):
self.code = code
self.name = name
def getCode(self):
return self.code
def getName(self):
return self.name
class Marks:
historyMarks = 0
geographyMarks = 0
def __init__(self, historyMarks, geographyMarks):
self.historyMarks = historyMarks
self.geographyMarks = geographyMarks
def getHistoryMarks(self):
return self.historyMarks
def getGeographyMarks(self):
return self.geographyMarks
class Result(Student, Marks):
totalMarks = 0
percentage = 0
def __init__(self, code, name, historyMarks, geographyMarks):
Student.__init__(self, code, name)
Marks.__init__(self, historyMarks, geographyMarks)
self.totalMarks = historyMarks + geographyMarks
self.percentage = (historyMarks + geographyMarks) / 200 * 100
def getTotalMarks(self):
return self.totalMarks
def getPercentage(self):
return self.percentage
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
self.show()
def dispmessage(self):
resultObj=Result(self.ui.lineEditCode.text(), self.ui.lineEditName.text(), int(self.ui.lineEditHistoryMarks.text()), int(self.ui.lineEditGeographyMarks.text()))
self.ui.lineEditTotal.setText(str(resultObj.getTotalMarks()))
self.ui.lineEditPercentage.setText(str(resultObj.getPercentage()))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/callSimpleInheritance.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoSimpleInheritance import *
class Student:
name = ""
code = ""
def __init__(self, code, name):
self.code = code
self.name = name
def getCode(self):
return self.code
def getName(self):
return self.name
class Marks(Student):
historyMarks = 0
geographyMarks = 0
def __init__(self, code, name, historyMarks, geographyMarks):
Student.__init__(self,code,name)
self.historyMarks = historyMarks
self.geographyMarks = geographyMarks
def getHistoryMarks(self):
return self.historyMarks
def getGeographyMarks(self):
return self.geographyMarks
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
self.show()
def dispmessage(self):
marksObj=Marks(self.ui.lineEditCode.text(), self.ui.lineEditName.text(), self.ui.lineEditHistoryMarks.text(), self.ui.lineEditGeographyMarks.text())
self.ui.labelResponse.setText("Code: "+marksObj.getCode()+", Name:"+marksObj.getName()+"\nHistory Marks:"+marksObj.getHistoryMarks()+", Geography Marks:"+marksObj.getGeographyMarks())
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/callStudentClass.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from demoStudentClass import *
class Student:
name = ""
code = ""
def __init__(self, code, name):
self.code = code
self.name = name
def getCode(self):
return self.code
def getName(self):
return self.name
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.ButtonClickMe.clicked.connect(self.dispmessage)
self.show()
def dispmessage(self):
studentObj=Student(self.ui.lineEditCode.text(), self.ui.lineEditName.text())
self.ui.labelResponse.setText("Code: "+studentObj.getCode()+", Name:"+studentObj.getName())
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/demoMultilevelInheritance.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoMultilevelInheritance.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(382, 322)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineEditName = QtWidgets.QLineEdit(Dialog)
self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditName.setFont(font)
self.lineEditName.setObjectName("lineEditName")
self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
self.ButtonClickMe.setGeometry(QtCore.QRect(150, 280, 101, 23))
font = QtGui.QFont()
font.setPointSize(11)
self.ButtonClickMe.setFont(font)
self.ButtonClickMe.setObjectName("ButtonClickMe")
self.lineEditCode = QtWidgets.QLineEdit(Dialog)
self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditCode.setFont(font)
self.lineEditCode.setObjectName("lineEditCode")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEditHistoryMarks = QtWidgets.QLineEdit(Dialog)
self.lineEditHistoryMarks.setGeometry(QtCore.QRect(140, 100, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditHistoryMarks.setFont(font)
self.lineEditHistoryMarks.setObjectName("lineEditHistoryMarks")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(20, 100, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Dialog)
self.label_4.setGeometry(QtCore.QRect(20, 140, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.lineEditGeographyMarks = QtWidgets.QLineEdit(Dialog)
self.lineEditGeographyMarks.setGeometry(QtCore.QRect(140, 140, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditGeographyMarks.setFont(font)
self.lineEditGeographyMarks.setObjectName("lineEditGeographyMarks")
self.lineEditPercentage = QtWidgets.QLineEdit(Dialog)
self.lineEditPercentage.setEnabled(False)
self.lineEditPercentage.setGeometry(QtCore.QRect(140, 220, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditPercentage.setFont(font)
self.lineEditPercentage.setObjectName("lineEditPercentage")
self.label_5 = QtWidgets.QLabel(Dialog)
self.label_5.setGeometry(QtCore.QRect(20, 220, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.lineEditTotal = QtWidgets.QLineEdit(Dialog)
self.lineEditTotal.setEnabled(False)
self.lineEditTotal.setGeometry(QtCore.QRect(140, 180, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditTotal.setFont(font)
self.lineEditTotal.setObjectName("lineEditTotal")
self.label_6 = QtWidgets.QLabel(Dialog)
self.label_6.setGeometry(QtCore.QRect(20, 180, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Student Name"))
self.ButtonClickMe.setText(_translate("Dialog", "Click"))
self.label_2.setText(_translate("Dialog", "Student Code"))
self.label_3.setText(_translate("Dialog", "History Marks"))
self.label_4.setText(_translate("Dialog", "Geography Marks"))
self.label_5.setText(_translate("Dialog", "Percentage"))
self.label_6.setText(_translate("Dialog", "Total"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/demoMultilevelInheritance.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>322</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Name</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>140</x>
<y>60</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="ButtonClickMe">
<property name="geometry">
<rect>
<x>150</x>
<y>280</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Click</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditCode">
<property name="geometry">
<rect>
<x>140</x>
<y>20</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Code</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditHistoryMarks">
<property name="geometry">
<rect>
<x>140</x>
<y>100</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>History Marks</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Geography Marks</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditGeographyMarks">
<property name="geometry">
<rect>
<x>140</x>
<y>140</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lineEditPercentage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>140</x>
<y>220</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Percentage</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditTotal">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>140</x>
<y>180</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>20</x>
<y>180</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Total</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter04/demoMultipleInheritance.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoMultipleInheritance.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(382, 322)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineEditName = QtWidgets.QLineEdit(Dialog)
self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditName.setFont(font)
self.lineEditName.setObjectName("lineEditName")
self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
self.ButtonClickMe.setGeometry(QtCore.QRect(150, 280, 101, 23))
font = QtGui.QFont()
font.setPointSize(11)
self.ButtonClickMe.setFont(font)
self.ButtonClickMe.setObjectName("ButtonClickMe")
self.lineEditCode = QtWidgets.QLineEdit(Dialog)
self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditCode.setFont(font)
self.lineEditCode.setObjectName("lineEditCode")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEditHistoryMarks = QtWidgets.QLineEdit(Dialog)
self.lineEditHistoryMarks.setGeometry(QtCore.QRect(140, 100, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditHistoryMarks.setFont(font)
self.lineEditHistoryMarks.setObjectName("lineEditHistoryMarks")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(20, 100, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Dialog)
self.label_4.setGeometry(QtCore.QRect(20, 140, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.lineEditGeographyMarks = QtWidgets.QLineEdit(Dialog)
self.lineEditGeographyMarks.setGeometry(QtCore.QRect(140, 140, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditGeographyMarks.setFont(font)
self.lineEditGeographyMarks.setObjectName("lineEditGeographyMarks")
self.lineEditPercentage = QtWidgets.QLineEdit(Dialog)
self.lineEditPercentage.setEnabled(False)
self.lineEditPercentage.setGeometry(QtCore.QRect(140, 220, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditPercentage.setFont(font)
self.lineEditPercentage.setObjectName("lineEditPercentage")
self.label_5 = QtWidgets.QLabel(Dialog)
self.label_5.setGeometry(QtCore.QRect(20, 220, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.lineEditTotal = QtWidgets.QLineEdit(Dialog)
self.lineEditTotal.setEnabled(False)
self.lineEditTotal.setGeometry(QtCore.QRect(140, 180, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditTotal.setFont(font)
self.lineEditTotal.setObjectName("lineEditTotal")
self.label_6 = QtWidgets.QLabel(Dialog)
self.label_6.setGeometry(QtCore.QRect(20, 180, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Student Name"))
self.ButtonClickMe.setText(_translate("Dialog", "Click"))
self.label_2.setText(_translate("Dialog", "Student Code"))
self.label_3.setText(_translate("Dialog", "History Marks"))
self.label_4.setText(_translate("Dialog", "Geography Marks"))
self.label_5.setText(_translate("Dialog", "Percentage"))
self.label_6.setText(_translate("Dialog", "Total"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/demoMultipleInheritance.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>322</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Name</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>140</x>
<y>60</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="ButtonClickMe">
<property name="geometry">
<rect>
<x>150</x>
<y>280</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Click</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditCode">
<property name="geometry">
<rect>
<x>140</x>
<y>20</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Code</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditHistoryMarks">
<property name="geometry">
<rect>
<x>140</x>
<y>100</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>History Marks</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Geography Marks</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditGeographyMarks">
<property name="geometry">
<rect>
<x>140</x>
<y>140</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lineEditPercentage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>140</x>
<y>220</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Percentage</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditTotal">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>140</x>
<y>180</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>20</x>
<y>180</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Total</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter04/demoSimpleInheritance.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoSimpleInheritance.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(402, 291)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label.setFont(font)
self.label.setObjectName("label")
self.labelResponse = QtWidgets.QLabel(Dialog)
self.labelResponse.setGeometry(QtCore.QRect(10, 179, 361, 41))
font = QtGui.QFont()
font.setPointSize(11)
self.labelResponse.setFont(font)
self.labelResponse.setText("")
self.labelResponse.setObjectName("labelResponse")
self.lineEditName = QtWidgets.QLineEdit(Dialog)
self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditName.setFont(font)
self.lineEditName.setObjectName("lineEditName")
self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
self.ButtonClickMe.setGeometry(QtCore.QRect(140, 250, 101, 23))
font = QtGui.QFont()
font.setPointSize(11)
self.ButtonClickMe.setFont(font)
self.ButtonClickMe.setObjectName("ButtonClickMe")
self.lineEditCode = QtWidgets.QLineEdit(Dialog)
self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditCode.setFont(font)
self.lineEditCode.setObjectName("lineEditCode")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEditHistoryMarks = QtWidgets.QLineEdit(Dialog)
self.lineEditHistoryMarks.setGeometry(QtCore.QRect(140, 100, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditHistoryMarks.setFont(font)
self.lineEditHistoryMarks.setObjectName("lineEditHistoryMarks")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(20, 100, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Dialog)
self.label_4.setGeometry(QtCore.QRect(20, 140, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.lineEditGeographyMarks = QtWidgets.QLineEdit(Dialog)
self.lineEditGeographyMarks.setGeometry(QtCore.QRect(140, 140, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditGeographyMarks.setFont(font)
self.lineEditGeographyMarks.setObjectName("lineEditGeographyMarks")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Student Name"))
self.ButtonClickMe.setText(_translate("Dialog", "Click"))
self.label_2.setText(_translate("Dialog", "Student Code"))
self.label_3.setText(_translate("Dialog", "History Marks"))
self.label_4.setText(_translate("Dialog", "Geography Marks"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/demoSimpleInheritance.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<height>291</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Name</string>
</property>
</widget>
<widget class="QLabel" name="labelResponse">
<property name="geometry">
<rect>
<x>10</x>
<y>179</y>
<width>361</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>140</x>
<y>60</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="ButtonClickMe">
<property name="geometry">
<rect>
<x>140</x>
<y>250</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Click</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditCode">
<property name="geometry">
<rect>
<x>140</x>
<y>20</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Code</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditHistoryMarks">
<property name="geometry">
<rect>
<x>140</x>
<y>100</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>History Marks</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Geography Marks</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditGeographyMarks">
<property name="geometry">
<rect>
<x>140</x>
<y>140</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter04/demoStudentClass.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoStudentClass.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(412, 208)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 60, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label.setFont(font)
self.label.setObjectName("label")
self.labelResponse = QtWidgets.QLabel(Dialog)
self.labelResponse.setGeometry(QtCore.QRect(30, 120, 361, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.labelResponse.setFont(font)
self.labelResponse.setText("")
self.labelResponse.setObjectName("labelResponse")
self.lineEditName = QtWidgets.QLineEdit(Dialog)
self.lineEditName.setGeometry(QtCore.QRect(140, 60, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditName.setFont(font)
self.lineEditName.setObjectName("lineEditName")
self.ButtonClickMe = QtWidgets.QPushButton(Dialog)
self.ButtonClickMe.setGeometry(QtCore.QRect(140, 170, 101, 23))
font = QtGui.QFont()
font.setPointSize(11)
self.ButtonClickMe.setFont(font)
self.ButtonClickMe.setObjectName("ButtonClickMe")
self.lineEditCode = QtWidgets.QLineEdit(Dialog)
self.lineEditCode.setGeometry(QtCore.QRect(140, 20, 201, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.lineEditCode.setFont(font)
self.lineEditCode.setObjectName("lineEditCode")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 20, 121, 20))
font = QtGui.QFont()
font.setPointSize(11)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Student Name"))
self.ButtonClickMe.setText(_translate("Dialog", "Click"))
self.label_2.setText(_translate("Dialog", "Student Code"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
================================================
FILE: Chapter04/demoStudentClass.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>412</width>
<height>208</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Name</string>
</property>
</widget>
<widget class="QLabel" name="labelResponse">
<property name="geometry">
<rect>
<x>30</x>
<y>120</y>
<width>361</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>140</x>
<y>60</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QPushButton" name="ButtonClickMe">
<property name="geometry">
<rect>
<x>140</x>
<y>170</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Click</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditCode">
<property name="geometry">
<rect>
<x>140</x>
<y>20</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Student Code</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
================================================
FILE: Chapter05/callColorDialog.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication, QColorDialog
from PyQt5.QtGui import QColor
from demoColorDialog import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
col = QColor(0, 0, 0)
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.frameColor.setStyleSheet("QWidget { background-color: %s }" % col.name())
self.ui.pushButtonColor.clicked.connect(self.dispcolor)
self.show()
def dispcolor(self):
col = QColorDialog.getColor()
if col.isValid():
self.ui.frameColor.setStyleSheet("QWidget { background-color: %s }" % col.name())
self.ui.labelColor.setText("You have selected the color with code: " + str(col.name()))
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter05/callFileDialog.pyw
================================================
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QAction, QFileDialog
from demoFileDialog import *
class MyForm(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.actionOpen.triggered.connect(self.openFileDialog)
self.ui.actionSave.triggered.connect(self.saveFileDialog)
self.show()
def openFileDialog(self):
fname = QFileDialog.getOpenFileName(self, 'Open file', '/home')
if fname[0]:
f = open(fname[0], 'r')
with f:
data = f.read()
self.ui.textEdit.setText(data)
def saveFileDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fileName, _ = QFileDialog.getSaveFileName(self,"QFileDialog.getSaveFileName()","","All Files (*);;Text Files (*.txt)", options=options)
f = open(fileName,'w')
text = self.ui.textEdit.toPlainText()
f.write(text)
f.close()
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter05/callFontDialog.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication, QFontDialog
from demoFontDialog import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.pushButtonFont.clicked.connect(self.changefont)
self.show()
def changefont(self):
font, ok = QFontDialog.getFont()
if ok:
self.ui.textEdit.setFont(font)
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter05/callInputDialog.pyw
================================================
import sys
from PyQt5.QtWidgets import QDialog, QApplication, QInputDialog
from demoInputDialog import *
class MyForm(QDialog):
def __init__(self):
super().__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.pushButtonCountry.clicked.connect(self.dispmessage)
self.show()
def dispmessage(self):
countries = ("Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan")
countryName, ok = QInputDialog.getItem(self, "Input Dialog", "List of countries", countries, 0, False)
if ok and countryName:
self.ui.lineEditCountry.setText(countryName)
if __name__=="__main__":
app = QApplication(sys.argv)
w = MyForm()
w.show()
sys.exit(app.exec_())
================================================
FILE: Chapter05/demoColorDialog.py
================================================
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demoColorDialog.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 176)
self.frameColor = QtWidgets.QFrame(Dialog)
self.frameColor.setGeometry(QtCore.QRect(210, 20, 120, 80))
font = QtGui.QFont()
font.setPointSize(12)
self.frameColor.setFont(font)
self.frameColor.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frameColor.setFrameShadow(QtWidgets.QFrame.Raised)
self.frameColor.setObjectName("frameColor")
self.pushButtonColor = QtWidgets.QPushButton(Dialog)
self.pushButtonColor.setGeometry(QtCore.QRect(30, 40, 151, 23))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonColor.setFont(font)
self.pushButtonColor.setObjectName("pushButtonColor")
self.labelColor = QtWidgets.QLabel(Dialog)
self.labelColor.setGeometry(QtCore.QRect(30, 130, 351, 20))
font = QtGui.QFont()
font.setPointSize(12)
self.labelColor.setFont(font)
self.labelColor.setText("")
self.labelColor.setObjectName("labelColor")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButtonColor.setText(_translate("Dialog", "Choose color"))
================================================
FILE: Chapter05/demoColorDialog.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>176</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QFrame" name="frameColor">
<property name="geometry">
<rect>
<x>210</x>
<y>20</y>
<width>120</width>
<height>80</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="QPushButton" name="pushButtonColor">
<property name="geometry">
<rect>
<x>30</x>
<y>40</y>
<width>151</width>
<height>23</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Choose color</string>
</property>
</widget>
<widget class="QLabel" name="labelColor">
<property name="geometry">
<rect>
<x>30</x>
<y>130</y>
<width>351</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
=====
gitextract_2qkmchcu/ ├── Chapter01/ │ ├── 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/ │ ├── 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
SYMBOL INDEX (93 symbols across 31 files)
FILE: Chapter01/demoCheckBox1.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 55) | def retranslateUi(self, Dialog):
FILE: Chapter01/demoCheckBox2.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 118) | def retranslateUi(self, Dialog):
FILE: Chapter01/demoLineEdit.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 43) | def retranslateUi(self, Dialog):
FILE: Chapter01/demoRadioButton1.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 50) | def retranslateUi(self, Dialog):
FILE: Chapter01/demoRadioButton2.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 92) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoCalculator.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 74) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoComboBox.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 42) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoFontComboBox.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 40) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoListWidget1.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 48) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoListWidget2.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 54) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoListWidget3.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 43) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoListWidgetOp.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 61) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoProgressBar.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 38) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoScrollBar.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 77) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoSignalSlot1.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 34) | def retranslateUi(self, Dialog):
FILE: Chapter02/demoSpinBox.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 73) | def retranslateUi(self, Dialog):
FILE: Chapter03/demoCalendar.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 25) | def retranslateUi(self, Dialog):
FILE: Chapter03/demoLCD.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 22) | def retranslateUi(self, Dialog):
FILE: Chapter03/demoTabWidget.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 98) | def retranslateUi(self, Dialog):
FILE: Chapter03/reservehotel.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 81) | def retranslateUi(self, Dialog):
FILE: Chapter04/LineEditClass.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 43) | def retranslateUi(self, Dialog):
FILE: Chapter04/demoMultilevelInheritance.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 99) | def retranslateUi(self, Dialog):
FILE: Chapter04/demoMultipleInheritance.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 99) | def retranslateUi(self, Dialog):
FILE: Chapter04/demoSimpleInheritance.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 80) | def retranslateUi(self, Dialog):
FILE: Chapter04/demoStudentClass.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 56) | def retranslateUi(self, Dialog):
FILE: Chapter05/demoColorDialog.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 40) | def retranslateUi(self, Dialog):
FILE: Chapter05/demoFileDialog.py
class Ui_MainWindow (line 11) | class Ui_MainWindow(object):
method setupUi (line 12) | def setupUi(self, MainWindow):
method retranslateUi (line 41) | def retranslateUi(self, MainWindow):
FILE: Chapter05/demoFontDialog.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 28) | def retranslateUi(self, Dialog):
FILE: Chapter05/demoInputDialog.py
class Ui_Dialog (line 4) | class Ui_Dialog(object):
method setupUi (line 5) | def setupUi(self, Dialog):
method retranslateUi (line 30) | def retranslateUi(self, Dialog):
FILE: Chapter07/demoBrowser.py
class Ui_Dialog (line 11) | class Ui_Dialog(object):
method setupUi (line 12) | def setupUi(self, Dialog):
method retranslateUi (line 40) | def retranslateUi(self, Dialog):
FILE: Chapter07/demoMenuBar.py
class Ui_MainWindow (line 11) | class Ui_MainWindow(object):
method setupUi (line 12) | def setupUi(self, MainWindow):
method retranslateUi (line 71) | def retranslateUi(self, MainWindow):
Condensed preview — 94 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (250K chars).
[
{
"path": "Chapter01/callCheckBox1.pyw",
"chars": 1073,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog\r\nfrom PyQt5.QtWidgets import QApplication, QWidget, QPushButton\r\nfrom "
},
{
"path": "Chapter01/callCheckBox2.pyw",
"chars": 1709,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog\r\nfrom PyQt5.QtWidgets import QApplication, QWidget, QPushButton\r\nfrom "
},
{
"path": "Chapter01/callLineEdit.pyw",
"chars": 554,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoLineEdit import *\r\n\r\nclass MyForm(QDialog):\r"
},
{
"path": "Chapter01/callRadioButton1.pyw",
"chars": 959,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoRadioButton1 import *\r\n\r\nclass MyForm(QDialo"
},
{
"path": "Chapter01/callRadioButton2.pyw",
"chars": 1741,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoRadioButton2 import *\r\n\r\nclass MyForm(QDialo"
},
{
"path": "Chapter01/demoCheckBox1.py",
"chars": 3007,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoCheckBox1.ui'\r\n#\r\n# Created by: PyQ"
},
{
"path": "Chapter01/demoCheckBox2.py",
"chars": 6722,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoCheckbox2.ui'\r\n#\r\n# Created by: PyQ"
},
{
"path": "Chapter01/demoCheckbox1.ui",
"chars": 2796,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter01/demoCheckbox2.ui",
"chars": 5965,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter01/demoLineEdit.py",
"chars": 1961,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoLineEdit.ui'\r\n#\r\n# Created by: PyQt"
},
{
"path": "Chapter01/demoLineEdit.ui",
"chars": 1890,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter01/demoRadioButton1.py",
"chars": 2787,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoRadioButton1.ui'\r\n#\r\n# Created by: "
},
{
"path": "Chapter01/demoRadioButton1.ui",
"chars": 2415,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter01/demoRadioButton2.py",
"chars": 5157,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoRadioButton2.ui'\r\n#\r\n# Created by: "
},
{
"path": "Chapter01/demoRadioButton2.ui",
"chars": 4250,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/callCalculator.pyw",
"chars": 2301,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoCalculator import *\r\n\r\nclass MyForm(QDialog)"
},
{
"path": "Chapter02/callComboBox.pyw",
"chars": 648,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoComboBox import *\r\n\r\nclass MyForm(QDialog):\r"
},
{
"path": "Chapter02/callFontComboBox.pyw",
"chars": 769,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoFontComboBox import *\r\n\r\nclass MyForm(QDialo"
},
{
"path": "Chapter02/callListWidget1.pyw",
"chars": 615,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoListWidget1 import *\r\n\r\nclass MyForm(QDialog"
},
{
"path": "Chapter02/callListWidget2.pyw",
"chars": 772,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoListWidget2 import *\r\n\r\nclass MyForm(QDialog"
},
{
"path": "Chapter02/callListWidget3.pyw",
"chars": 653,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoListWidget3 import *\r\n\r\nclass MyForm(QDialog"
},
{
"path": "Chapter02/callListWidgetOp.pyw",
"chars": 1563,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication, QInputDialog, QListWidgetItem\r\n\r\nfrom demoListWidgetOp "
},
{
"path": "Chapter02/callProgressBar.pyw",
"chars": 587,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoProgressBar import *\r\n\r\nclass MyForm(QDialog"
},
{
"path": "Chapter02/callScrollBar.pyw",
"chars": 1218,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoScrollBar import *\r\n\r\nclass MyForm(QDialog):"
},
{
"path": "Chapter02/calldemoSignalSlot1.pyw",
"chars": 385,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoSignalSlot1 import *\r\n\r\nclass MyForm(QDialog"
},
{
"path": "Chapter02/calldemoSpinner.pyw",
"chars": 1390,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoSpinBox import *\r\n\r\nclass MyForm(QDialog):\r\n"
},
{
"path": "Chapter02/demoCalculator.py",
"chars": 3769,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoCalculator.ui'\r\n#\r\n# Created by: Py"
},
{
"path": "Chapter02/demoCalculator.ui",
"chars": 3780,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoComboBox.py",
"chars": 2409,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoComboBox.ui'\r\n#\r\n# Created by: PyQt"
},
{
"path": "Chapter02/demoComboBox.ui",
"chars": 1943,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoFontComboBox.py",
"chars": 2005,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoFontComboBox.ui'\r\n#\r\n# Created by: "
},
{
"path": "Chapter02/demoFontComboBox.ui",
"chars": 1726,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoListWidget1.py",
"chars": 2857,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoListWidget1.ui'\r\n#\r\n# Created by: P"
},
{
"path": "Chapter02/demoListWidget1.ui",
"chars": 2071,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoListWidget2.py",
"chars": 3545,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoListWidget2.ui'\r\n#\r\n# Created by: P"
},
{
"path": "Chapter02/demoListWidget2.ui",
"chars": 2524,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoListWidget3.py",
"chars": 2203,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoListWidget3.ui'\r\n#\r\n# Created by: P"
},
{
"path": "Chapter02/demoListWidget3.ui",
"chars": 1851,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoListWidgetOp.py",
"chars": 3227,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoListWidgetOp.ui'\r\n#\r\n# Created by: "
},
{
"path": "Chapter02/demoListWidgetOp.ui",
"chars": 3004,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoProgressBar.py",
"chars": 1899,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoProgressBar.ui'\r\n#\r\n# Created by: P"
},
{
"path": "Chapter02/demoProgressBar.ui",
"chars": 1587,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoScrollBar.py",
"chars": 4241,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoScrollBar.ui'\r\n#\r\n# Created by: PyQ"
},
{
"path": "Chapter02/demoScrollBar.ui",
"chars": 3944,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoSignalSlot1.py",
"chars": 1892,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoSignalSlot1.ui'\r\n#\r\n# Created by: P"
},
{
"path": "Chapter02/demoSignalSlot1.ui",
"chars": 2455,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter02/demoSpinBox.py",
"chars": 3564,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoSpinBox.ui'\r\n#\r\n# Created by: PyQt5"
},
{
"path": "Chapter02/demoSpinBox.ui",
"chars": 3500,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter03/DemoTableWidget.ui",
"chars": 1230,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter03/callCalendar.pyw",
"chars": 613,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoCalendar import *\r\n\r\nclass MyForm(QDialog):\r"
},
{
"path": "Chapter03/callLCD.pyw",
"chars": 641,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoLCD import *\r\n\r\nclass MyForm(QDialog):\r\n "
},
{
"path": "Chapter03/callTableWidget.pyw",
"chars": 887,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication,QTableWidgetItem\r\nfrom DemoTableWidget import *\r\n\r\nclass"
},
{
"path": "Chapter03/computeRoomRent.pyw",
"chars": 1569,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom reservehotel import *\r\n\r\nclass MyForm(QDialog):\r"
},
{
"path": "Chapter03/demoCalendar.py",
"chars": 1224,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoCalendar.ui'\r\n#\r\n# Created by: PyQt"
},
{
"path": "Chapter03/demoCalendar.ui",
"chars": 841,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter03/demoLCD.py",
"chars": 1023,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoLCD.ui'\r\n#\r\n# Created by: PyQt5 UI "
},
{
"path": "Chapter03/demoLCD.ui",
"chars": 614,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter03/demoTabWidget.py",
"chars": 6648,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoTabWidget.ui'\r\n#\r\n# Created by: PyQ"
},
{
"path": "Chapter03/reservehotel.py",
"chars": 3779,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'reservehotel.ui'\r\n#\r\n# Created by: PyQt"
},
{
"path": "Chapter03/reservehotel.ui",
"chars": 4076,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter04/LineEditClass.py",
"chars": 1961,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoLineEdit.ui'\r\n#\r\n# Created by: PyQt"
},
{
"path": "Chapter04/LineEditClass.ui",
"chars": 1890,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter04/callLineEditClass.pyw",
"chars": 757,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom LineEditClass import *\r\n\r\nclass Student:\r\n na"
},
{
"path": "Chapter04/callMultilevelInheritance.pyw",
"chars": 1955,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoMultilevelInheritance import *\r\n\r\nclass Stud"
},
{
"path": "Chapter04/callMultipleInheritance.pyw",
"chars": 1931,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoMultipleInheritance import *\r\n\r\nclass Studen"
},
{
"path": "Chapter04/callSimpleInheritance.pyw",
"chars": 1515,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoSimpleInheritance import *\r\n\r\nclass Student:"
},
{
"path": "Chapter04/callStudentClass.pyw",
"chars": 918,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication\r\n\r\nfrom demoStudentClass import *\r\n\r\nclass Student:\r\n "
},
{
"path": "Chapter04/demoMultilevelInheritance.py",
"chars": 5121,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoMultilevelInheritance.ui'\r\n#\r\n# Cre"
},
{
"path": "Chapter04/demoMultilevelInheritance.ui",
"chars": 5200,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter04/demoMultipleInheritance.py",
"chars": 5119,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoMultipleInheritance.ui'\r\n#\r\n# Creat"
},
{
"path": "Chapter04/demoMultipleInheritance.ui",
"chars": 5200,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter04/demoSimpleInheritance.py",
"chars": 4093,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoSimpleInheritance.ui'\r\n#\r\n# Created"
},
{
"path": "Chapter04/demoSimpleInheritance.ui",
"chars": 4019,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter04/demoStudentClass.py",
"chars": 2764,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoStudentClass.ui'\r\n#\r\n# Created by: "
},
{
"path": "Chapter04/demoStudentClass.ui",
"chars": 2579,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter05/callColorDialog.pyw",
"chars": 911,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication, QColorDialog\r\nfrom PyQt5.QtGui import QColor\r\n\r\nfrom de"
},
{
"path": "Chapter05/callFileDialog.pyw",
"chars": 1219,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QMainWindow, QApplication, QAction, QFileDialog\r\n\r\nfrom demoFileDialog import "
},
{
"path": "Chapter05/callFontDialog.pyw",
"chars": 603,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication, QFontDialog\r\n\r\n\r\nfrom demoFontDialog import *\r\n\r\nclass "
},
{
"path": "Chapter05/callInputDialog.pyw",
"chars": 856,
"preview": "import sys\r\n\r\nfrom PyQt5.QtWidgets import QDialog, QApplication, QInputDialog\r\n\r\nfrom demoInputDialog import *\r\n\r\nclass "
},
{
"path": "Chapter05/demoColorDialog.py",
"chars": 1738,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoColorDialog.ui'\r\n#\r\n# Created by: P"
},
{
"path": "Chapter05/demoColorDialog.ui",
"chars": 1655,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter05/demoFileDialog.py",
"chars": 2238,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoFileDialog.ui'\r\n#\r\n# Created by: Py"
},
{
"path": "Chapter05/demoFileDialog.ui",
"chars": 1573,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>MainWindow</class>\r\n <widget class=\"QMainWindow\" nam"
},
{
"path": "Chapter05/demoFontDialog.py",
"chars": 1181,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoFontDialog.ui'\r\n#\r\n# Created by: Py"
},
{
"path": "Chapter05/demoFontDialog.ui",
"chars": 1013,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter05/demoInputDialog.py",
"chars": 1661,
"preview": "\r\nfrom PyQt5 import QtCore, QtGui, QtWidgets\r\n\r\nclass Ui_Dialog(object):\r\n def setupUi(self, Dialog):\r\n Dialog"
},
{
"path": "Chapter05/demoInputDialog.ui",
"chars": 1512,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "Chapter07/callServer.pyw",
"chars": 2217,
"preview": "import sys, time\r\nimport socket\r\nfrom PyQt5 import QtGui\r\nfrom PyQt5 import QtCore\r\nfrom PyQt5.QtWidgets import QApplica"
},
{
"path": "Chapter07/demoBrowser.py",
"chars": 2006,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoBrowser.ui'\r\n#\r\n# Created by: PyQt5"
},
{
"path": "Chapter07/demoDockWidget.ui",
"chars": 3603,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>MainWindow</class>\r\n <widget class=\"QMainWindow\" nam"
},
{
"path": "Chapter07/demoMenuBar.py",
"chars": 5330,
"preview": "# -*- coding: utf-8 -*-\r\n\r\n# Form implementation generated from reading ui file 'demoMenuBar.ui'\r\n#\r\n# Created by: PyQt5"
},
{
"path": "Chapter07/demoTabWidget.ui",
"chars": 7406,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ui version=\"4.0\">\r\n <class>Dialog</class>\r\n <widget class=\"QDialog\" name=\"Dialo"
},
{
"path": "LICENSE",
"chars": 1062,
"preview": "MIT License\n\nCopyright (c) 2018 Packt\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof t"
},
{
"path": "README.md",
"chars": 6327,
"preview": "\n\n\n# Qt5 Python GUI Programming Cookbook\n\n<a href=\"https://www.packtpub.com/application-development/qt5-python-gui-progr"
}
]
About this extraction
This page contains the full source code of the PacktPublishing/Qt5-Python-GUI-Programming-Cookbook GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 94 files (220.9 KB), approximately 62.3k tokens, and a symbol index with 93 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.