I have attached the code: please Help:
import sys
from math import sqrt
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QPixmap
class Window(QDialog):
def init(self):
super(Window, self).init()
self.setWindowTitle(“Footing Design”)
self.setGeometry(400, 50, 800, 1000)
widget = QWidget()
layout = QVBoxLayout(widget)
self.formGroupBox = QGroupBox("Footing Design Form")
self.formGroupBox.setFixedSize(800, 1000)
self.pushButton = QPushButton('Proceed', self.formGroupBox)
self.pushButton.setGeometry(100, 650, 100, 30)
# Load the image into a QPixmap and set it to a QLabel
pixmap = QPixmap("C:/Users/TCC2/Desktop/a.png").scaled(100, 100)
#self.pixmap = QPixmap("C:/Users/TCC2/Desktop/a.png").scaled(200, 200)
#self.label = QLabel(self)
#self.label.setPixmap(self.pixmap)
#self.label.setFixedSize(200, 200)
self.label = QLabel()
self.label.setFixedSize(100,100)
self.label.setPixmap(pixmap)
# Create a vertical layout for the groupbox and add the label to it
groupBoxLayout = QVBoxLayout(self.formGroupBox)
groupBoxLayout.addWidget(self.label)
layout.addWidget(self.formGroupBox)
self.setLayout(layout)
# creating field to take input for dl
self.dl = QLineEdit()
self.dl.setFixedSize(100, 20)
# creating field to take input for ll
self.ll = QLineEdit()
self.ll.setFixedSize(100, 20)
# creating field to take input for asp
self.asp = QLineEdit()
self.asp.setFixedSize(100, 20)
# creating field to take input for cs
self.cs = QLineEdit()
self.cs.setFixedSize(100, 20)
# creating field to take input for ss
self.ss = QLineEdit()
self.ss.setFixedSize(100, 20)
# creating field to take input for ds
self.ds = QLineEdit()
self.ds.setFixedSize(100, 20)
self.ds.setText("120")
# creating field to take input for dc
self.dc = QLineEdit()
self.dc.setFixedSize(100, 20)
self.dc.setText("150")
# creating field to take input for df
self.df = QLineEdit()
self.df.setFixedSize(100, 20)
# creating field to take input for ft
self.ft = QLineEdit()
self.ft.setFixedSize(100, 20)
# creating field to take input for cs1
self.cs1 = QLineEdit()
self.cs1.setFixedSize(100, 20)
# creating field to take input for cs2
self.cs2 = QLineEdit()
self.cs2.setFixedSize(100, 20)
# creating field to take input for refss
self.refss = QLineEdit()
self.refss.setFixedSize(100, 20)
self.refss.setText("4")
# creating field to take input for refsl
self.refsl = QLineEdit()
self.refsl.setFixedSize(100, 20)
self.refsl.setText("4")
# Display message start here
# areaRequiredMessage for display the result of rfa value
self.areaRequiredMessage = QLineEdit()
self.areaRequiredMessage.setReadOnly(True)
self.areaRequiredMessage.setStyleSheet("background-color: #ffc512")
self.areaRequiredMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of dps value
self.refaMessage = QLineEdit()
self.refaMessage.setReadOnly(True)
self.refaMessage.setStyleSheet("background-color: #ffc512")
self.refaMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of dps value
self.dpsMessage = QLineEdit()
self.dpsMessage.setReadOnly(True)
self.dpsMessage.setStyleSheet("background-color: #00ffff")
self.dpsMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of cps value
self.cpsMessage = QLineEdit()
self.cpsMessage.setReadOnly(True)
self.cpsMessage.setStyleSheet("background-color: #00ffff")
self.cpsMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of dbs value
self.dbsMessage = QLineEdit()
self.dbsMessage.setReadOnly(True)
self.dbsMessage.setStyleSheet("background-color: #a0cade")
self.dbsMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of cbs value
self.cbsMessage = QLineEdit()
self.cbsMessage.setReadOnly(True)
self.cbsMessage.setStyleSheet("background-color: #a0cade")
self.cbsMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of mul value
self.mulMessage = QLineEdit()
self.mulMessage.setReadOnly(True)
self.mulMessage.setStyleSheet("background-color: #ff7fff")
self.mulMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of mul value
self.musMessage = QLineEdit()
self.musMessage.setReadOnly(True)
self.musMessage.setStyleSheet("background-color: #ff7f7f")
self.musMessage.setFixedSize(100, 20)
# areaRequiredMessage for display the result of mul value
self.aslMessage = QLineEdit()
self.aslMessage.setReadOnly(True)
self.aslMessage.setStyleSheet("background-color: #ff7fff")
self.aslMessage.setFixedSize(100, 20)
self.assMessage = QLineEdit()
self.assMessage.setReadOnly(True)
self.assMessage.setStyleSheet("background-color: #ff7f7f")
self.assMessage.setFixedSize(100, 20)
# End of taking user inputs
# creating combo box to select degree
self.degreeComboBox = QComboBox()
# calling the method that create the form
self.createForm()
# creating a dialog button for ok and cancel
# self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
# adding action when form is accepted
# self.buttonBox.accepted.connect(self.footingAreaCalculation)
#self.pushButton = QPushButton('Calculate', self)
# adding action when form is rejected
#self.buttonBox.rejected.connect(self.reject)
self.pushButton.clicked.connect(self.footingAreaCalculation)
# creating a vertical layout
mainLayout = QVBoxLayout()
# adding form group box to the layout
mainLayout.addWidget(self.formGroupBox)
# adding button box to the layout
# mainLayout.addWidget(self.pushButton)
# setting lay out
self.setLayout(mainLayout)
# get info method called when form is accepted
def getInfo(self):
print("cs2 : {0}".format(self.cs2.text()))
# closing the window
self.close()
# calculate necessary operation method
def footingAreaCalculation(self):
dl = float(self.dl.text())
ll = float(self.ll.text())
asp = float(self.asp.text())
cs = float(self.cs.text())
ss = float(self.ss.text())
ds = float(self.ds.text())
dc = float(self.dc.text())
df = float(self.df.text())
ft = float(self.ft.text())
cs1 = float(self.cs1.text())
cs2 = float(self.cs2.text())
refss = float(self.refss.text())
refsl = float(self.refsl.text())
# Net allowable soil pressure in ksf nas,,
# print("dl : {0}".format(self.dl.text()))
# print("ll : {0}".format(self.ll.text()))
#print("asp : {0}".format(self.asp.text()))
#print("cs : {0}".format(self.cs.text()))
# print("ss : {0}".format(self.ss.text()))
# print("ds : {0}".format(self.ds.text()))
# print("dc : {0}".format(self.dc.text()))
# print("df : {0}".format(self.df.text()))
#print("ft : {0}".format(self.ft.text()))
# print("cs1 : {0}".format(self.cs1.text()))
# print("cs2 : {0}".format(self.cs2.text()))
# print("refss : {0}".format(self.refss.text()))
# print("refsl : {0}".format(self.refsl.text()))
# print("dps : {0}".format(self.dpsMessage.text()))
# print("cps : {0}".format(self.cpsMessage.text()))
# print("sbs : {0}".format(self.dbsMessage.text()))
# print("cbs : {0}".format(self.cbsMessage.text()))
# print("mul : {0}".format(self.mulMessage.text()))
# print("mus : {0}".format(self.musMessage.text()))
#print("asl : {0}".format(self.aslMessage.text()))
# print("ass : {0}".format(self.assMessage.text()))
# B4-(B9*B7/1000)-(B10/12*B8/1000)
# Calculate net allowable soil pressure calculation
self.nas = asp - ((df * ds) / 1000) - ((ft / 12) * (dc / 1000))
#print("refsl : {0}".format(self.nas))
# required footing area in sft rfa,,
self.rfa = (dl + ll) / self.nas
#print("Required footing area in sft:{0}".format(self.rfa))
# set areaRequiredMessage to display the result of rfa value
self.areaRequiredMessage.setText('{:.2f}'.format(self.rfa))
# recommended footing area in sft
refa = refss * refsl
if refa<self.rfa:
print("Please increase footing Area")
# soil pressure at base in ksf spb,,
spb = ((1.2 * dl) + (1.6 * ll)) / refa
# effective footing thickness in inch,eft
eft = ft - 4
# punching shear check,,
# acting total punching shear load in kip apl
apl = spb * ((refss * refsl) - (((cs1 / 12) + (eft / 12)) * ((cs2 / 12) + (eft / 12))))
# print("apl : {0}".format(apl))
bnot = 2 * (cs1 + cs2 + (2 * eft)) / 12
# print("bnot : {0}".format(bnot))
# develop punching shear stress in psi dps
dps = (((apl / (bnot * eft)) * 12) * 1000) / 144
# conrete punching strength in psi cps,,
cps = 0.85 * 4 * math.sqrt(cs * 1000)
if dps < cps:
print("Punching shear check okay")
else:
print("Failed against Punching shear")
# Beam shear Check,,
# acting beam shear load in kip abl
abl = (spb * refss) * ((0.5 * refsl) - ((0.5 * cs2) / 12) - (eft / 12))
#print("abl : {0}".format(abl))
# develop beam shear stress in psi dbs
dbs = (((abl / (refss * eft)) * (12 * 1000)) / 144)
# conrete beam shear strength in psi cbs,,
cbs = 0.85 * 2 * math.sqrt(cs * 1000)
if dbs < cbs:
print("Beam shear check okay")
else:
print("Failed against Beam shear")
# Moment calculation,,
# footing moment long direction in Kip-ft mul,,
mul = spb * (refss - cs2 / 12) ** 2 / 8
# footing moment short direction in Kip-ft mus,,
mus = spb * (refsl - cs1 / 12) ** 2 / 8
a1 = eft - sqrt(eft ** 2 - (2 * mus*12 / (0.85 * cs * 0.9 * 12)))
# print(" --- a1 : {0}".format(a1))
a2 = eft - sqrt(eft ** 2 - (2 * mul*12 / (0.85 * cs * 0.9 * 12)))
#print(" --- a2 : {0}".format(a2))
asl = (mul*12)/ (0.9* ss *(eft-a1/2))
#print(" --- asl : {0}".format(asl))
ass = (mus*12)/ (0.9* ss *(eft-a2/2))
# print(" --- ass : {0}".format(ass))
asmin = (200 * 12 * eft / ss)/1000
#print(" --- asmin : {0}".format(asmin))
if asl < asmin:
asl = asmin
if ass < asmin:
ass = asmin
# select bar size from drop down menu
abardia12 = 0.18
abardia16 = 0.31
abardia20 = 0.44
abardia22 = 0.59
abardia25 = 0.79
spacings12 = abardia12 * 12 / ass
spacings16 = abardia16 * 12 / ass
spacings20 = abardia20 * 12 / ass
spacings22 = abardia22 * 12 / ass
spacings25 = abardia25 * 12 / ass
spacingl12 = abardia12 * 12 / asl
spacingl16 = abardia16 * 12 / asl
spacingl20 = abardia20 * 12 / asl
spacingl22 = abardia22 * 12 / asl
spacingl25 = abardia25 * 12 / asl
print(" Short direction spacings(12mm) : {:.2f}".format(spacings12))
print(" Short direction spacings(16mm) : {:.2f}".format(spacings16))
print(" Short direction spacings(20mm) : {:.2f}".format(spacings20))
print(" Short direction spacings(22mm) : {:.2f}".format(spacings22))
print(" Short direction spacings(25mm) : {:.2f}".format(spacings25))
print(" Long direction spacings(12mm) : {:.2f}".format(spacingl12))
print(" Long direction spacings(16mm) : {:.2f}".format(spacingl16))
print(" Long direction spacings(20mm) : {:.2f}".format(spacingl20))
print(" Long direction spacings(22mm) : {:.2f}".format(spacingl22))
print(" Long direction spacings(25mm) : {:.2f}".format(spacingl25))
# development length
devlens = 0.04 * abardia25 * ss / cs
# print(" --- devlens : {0}".format(spacingl))
devlenp = 0.5 * (refss * 12 - cs1 - 3 - 3)
#print(" --- spacingl : {0}".format(spacingl))
if devlenp > devlens:
print("Development Length Check is Okay")
else:
print("Please check Development Length")
# set areaRequiredMessage to display the result of dps, cps, dbs, cbs value
# after float take 2 gigit
self.refaMessage.setText('{:.2f}'.format(refa))
self.dpsMessage.setText('{:.2f}'.format(dps))
self.cpsMessage.setText('{:.2f}'.format(cps))
self.dbsMessage.setText('{:.2f}'.format(dbs))
self.cbsMessage.setText('{:.2f}'.format(cbs))
self.mulMessage.setText('{:.2f}'.format(mul))
self.musMessage.setText('{:.2f}'.format(mus))
self.aslMessage.setText('{:.2f}'.format(asl))
self.assMessage.setText('{:.2f}'.format(ass))
#print("footing moment short direction in Kip-ft:{0}".format(mul))
#print("footing moment short direction in Kip-ft:{0}".format(mus))
# closing the window
# self.close()
# create form method
def createForm(self):
# creating a form layout
layout = QFormLayout()
# adding rows
# creating label to take input for dl
layout.addRow(QLabel("Total Dead Load (Kips)"), self.dl)
# creating label to take input for ll
layout.addRow(QLabel("Total Live Load (Kips)"), self.ll)
# creating label to take input for asp
layout.addRow(QLabel("Allowable soil pressure (ksf)"), self.asp)
# creating label to take input for cs
layout.addRow(QLabel("Concrete Strength (ksi)"), self.cs)
# creating label to take input for ss
layout.addRow(QLabel("Steel Strength (ksi)"), self.ss)
# creating label to take input for ds
layout.addRow(QLabel("Density of soil (lb/ft3)"), self.ds)
# creating label to take input for dc
layout.addRow(QLabel("Density of Concrete (lb/ft3)"), self.dc)
# creating label to take input for df
layout.addRow(QLabel("Depth of foundation (ft)"), self.df)
# creating label to take input for ft
layout.addRow(QLabel("Foting thickness (inch)"), self.ft)
# creating label to take input for cs1
layout.addRow(QLabel("Column size short direction (inch)"), self.cs1)
# creating label to take input for cs2
layout.addRow(QLabel("Column size long direction (inch)"), self.cs2)
# Area Required Message
layout.addRow(QLabel("Area Required (SFT) "), self.areaRequiredMessage)
# creating label to take input for cs2
layout.addRow(QLabel("Recommended footing size short direction (ft)"), self.refss)
# creating label to take input for cs2
layout.addRow(QLabel("Recommended footing size long direction (ft)"), self.refsl)
# creating label to take input for cs2
layout.addRow(QLabel("Provided footing Area (Sft)"), self.refaMessage)
# dps Message
layout.addRow(QLabel("Develop Punching Shear Stress (PSI) "), self.dpsMessage)
# cbs Message
layout.addRow(QLabel("Concrete Punching Shear Strength (PSI) "), self.cpsMessage)
# dbs Message
layout.addRow(QLabel("Develop Beam Shear Stress (PSI) "), self.dbsMessage)
# cbs Message
layout.addRow(QLabel("Concrete Beam Shear Strength (PSI) "), self.cbsMessage)
# cbs Message
layout.addRow(QLabel("Moment in Long direction (K-ft/ft) "), self.mulMessage)
# cbs Message
layout.addRow(QLabel("Moment in Short direction (K-ft/ft) "), self.musMessage)
# cbs Message
layout.addRow(QLabel("Steel Area in Long direction (Sq.in/ft) "), self.aslMessage)
# cbs Message
layout.addRow(QLabel("Steel Area in Short direction (Sq.in/ft) "), self.assMessage)
# setting layout
self.formGroupBox.setLayout(layout)
main method
if name == ‘main’:
# create pyqt5 app
app = QApplication(sys.argv)
# create the instance of our Window
window = Window()
# showing the window
window.show()
# start the app
sys.exit(app.exec())