Skip to content

Commit

Permalink
Code Files Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Vibhutig13 authored Jul 31, 2018
1 parent bf15a43 commit 56c26a3
Show file tree
Hide file tree
Showing 100 changed files with 7,338 additions and 0 deletions.
Binary file added Chapter01/__pycache__/demoLineEdit.cpython-35.pyc
Binary file not shown.
Binary file not shown.
33 changes: 33 additions & 0 deletions Chapter01/callCheckBox1.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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_())
46 changes: 46 additions & 0 deletions Chapter01/callCheckBox2.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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_())
22 changes: 22 additions & 0 deletions Chapter01/callLineEdit.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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_())
31 changes: 31 additions & 0 deletions Chapter01/callRadioButton1.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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_())
44 changes: 44 additions & 0 deletions Chapter01/callRadioButton2.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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_())
74 changes: 74 additions & 0 deletions Chapter01/demoCheckBox1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# -*- 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_())

133 changes: 133 additions & 0 deletions Chapter01/demoCheckBox2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# -*- 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"))

Loading

0 comments on commit 56c26a3

Please sign in to comment.