赞
踩
KFC点餐系统
废话不多说,直接上代码,首先是界面的代码
from PyQt5 import QtCore, QtGui, QtWidgets class ZS(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(719, 532) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.ZS = QtWidgets.QLabel(self.centralwidget) self.ZS.setGeometry(QtCore.QRect(10, 20, 71, 31)) self.ZS.setObjectName("ZS") self.ZJWB = QtWidgets.QLabel(self.centralwidget) self.ZJWB.setGeometry(QtCore.QRect(80, 50, 131, 191)) self.ZJWB.setObjectName("ZJWB") self.ZJTB = QtWidgets.QLabel(self.centralwidget) self.ZJTB.setGeometry(QtCore.QRect(300, 50, 131, 191)) self.ZJTB.setObjectName("ZJTB") self.Z_Price1 = QtWidgets.QLabel(self.centralwidget) self.Z_Price1.setGeometry(QtCore.QRect(80, 250, 81, 16)) self.Z_Price1.setObjectName("Z_Price1") self.Z_Price2 = QtWidgets.QLabel(self.centralwidget) self.Z_Price2.setGeometry(QtCore.QRect(310, 250, 81, 16)) self.Z_Price2.setObjectName("Z_Price2") self.ZOrder1 = QtWidgets.QSpinBox(self.centralwidget) self.ZOrder1.setGeometry(QtCore.QRect(90, 280, 42, 22)) self.ZOrder1.setObjectName("ZOrder1") self.ZOrder2 = QtWidgets.QSpinBox(self.centralwidget) self.ZOrder2.setGeometry(QtCore.QRect(310, 280, 42, 22)) self.ZOrder2.setObjectName("ZOrder2") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(540, 400, 75, 23)) self.pushButton.setObjectName("pushButton") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 719, 23)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.ZS.setText(_translate("MainWindow", ">汉堡主食:")) self.ZJWB.setText(_translate("MainWindow", "巨无霸")) self.ZJTB.setText(_translate("MainWindow", "鸡腿堡")) self.Z_Price1.setText(_translate("MainWindow", "20.0元/份")) self.Z_Price2.setText(_translate("MainWindow", "20.0元/份")) self.pushButton.setText(_translate("MainWindow", "加入清单"))
# -*- coding: utf-8 -*- from PyQt5 import QtCore, QtGui, QtWidgets class HD(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(719, 532) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.ZXHD = QtWidgets.QLabel(self.centralwidget) self.ZXHD.setGeometry(QtCore.QRect(10, 20, 71, 31)) self.ZXHD.setObjectName("ZXHD") self.HZJPJ = QtWidgets.QLabel(self.centralwidget) self.HZJPJ.setGeometry(QtCore.QRect(80, 50, 131, 191)) self.HZJPJ.setObjectName("HZJPJ") self.HJCTZ = QtWidgets.QLabel(self.centralwidget) self.HJCTZ.setGeometry(QtCore.QRect(300, 50, 131, 191)) self.HJCTZ.setObjectName("HJCTZ") self.HWSJ = QtWidgets.QLabel(self.centralwidget) self.HWSJ.setGeometry(QtCore.QRect(540, 50, 131, 191)) self.HWSJ.setObjectName("HWSJ") self.H_Price1 = QtWidgets.QLabel(self.centralwidget) self.H_Price1.setGeometry(QtCore.QRect(80, 250, 81, 16)) self.H_Price1.setObjectName("H_Price1") self.H_Price2 = QtWidgets.QLabel(self.centralwidget) self.H_Price2.setGeometry(QtCore.QRect(310, 250, 81, 16)) self.H_Price2.setObjectName("H_Price2") self.H_Price3 = QtWidgets.QLabel(self.centralwidget) self.H_Price3.setGeometry(QtCore.QRect(540, 250, 81, 16)) self.H_Price3.setObjectName("H_Price3") self.HOrder1 = QtWidgets.QSpinBox(self.centralwidget) self.HOrder1.setGeometry(QtCore.QRect(90, 280, 42, 22)) self.HOrder1.setObjectName("啤酒鸡翅") self.HOrder2 = QtWidgets.QSpinBox(self.centralwidget) self.HOrder2.setGeometry(QtCore.QRect(310, 280, 42, 22)) self.HOrder2.setObjectName("翅桶") self.HOrder3 = QtWidgets.QSpinBox(self.centralwidget) self.HOrder3.setGeometry(QtCore.QRect(550, 280, 42, 22)) self.HOrder3.setObjectName("万圣节") self.HJoin = QtWidgets.QPushButton(self.centralwidget) self.HJoin.setGeometry(QtCore.QRect(540, 400, 75, 23)) self.HJoin.setObjectName("HJoin") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 719, 23)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.ZXHD.setText(_translate("MainWindow", ">最新活动:")) self.HZJPJ.setText(_translate("MainWindow", "炸鸡啤酒干杯桶")) self.HJCTZ.setText(_translate("MainWindow", "鸡翅桶装")) self.HWSJ.setText(_translate("MainWindow", "万圣节日警报桶装")) self.H_Price1.setText(_translate("MainWindow", "115.0元/份")) self.H_Price2.setText(_translate("MainWindow", "80.0元/份")) self.H_Price3.setText(_translate("MainWindow", "100.0元/份")) self.HJoin.setText(_translate("MainWindow", "加入清单"))
from PyQt5 import QtCore, QtGui, QtWidgets
class JT(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(“MainWindow”)
MainWindow.resize(719, 532)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName(“centralwidget”)
self.JTTC = QtWidgets.QLabel(self.centralwidget)
self.JTTC.setGeometry(QtCore.QRect(10, 20, 71, 31))
self.JTTC.setObjectName(“JTTC”)
self.SRTC = QtWidgets.QLabel(self.centralwidget)
self.SRTC.setGeometry(QtCore.QRect(80, 50, 131, 191))
self.SRTC.setObjectName(“SRTC”)
self.WRTC = QtWidgets.QLabel(self.centralwidget)
self.WRTC.setGeometry(QtCore.QRect(300, 50, 131, 191))
self.WRTC.setObjectName(“WRTC”)
self.T_Price1 = QtWidgets.QLabel(self.centralwidget)
self.T_Price1.setGeometry(QtCore.QRect(80, 250, 81, 16))
self.T_Price1.setObjectName(“T_Price1”)
self.T_Price2 = QtWidgets.QLabel(self.centralwidget)
self.T_Price2.setGeometry(QtCore.QRect(310, 250, 81, 16))
self.T_Price2.setObjectName(“T_Price2”)
self.TOrder1 = QtWidgets.QSpinBox(self.centralwidget)
self.TOrder1.setGeometry(QtCore.QRect(90, 280, 42, 22))
self.TOrder1.setObjectName(“TOrder1”)
self.TOrder2 = QtWidgets.QSpinBox(self.centralwidget)
self.TOrder2.setGeometry(QtCore.QRect(310, 280, 42, 22))
self.TOrder2.setObjectName(“TOrder2”)
self.Tjoin = QtWidgets.QPushButton(self.centralwidget)
self.Tjoin.setGeometry(QtCore.QRect(540, 400, 75, 23))
self.Tjoin.setObjectName(“Tjoin”)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 719, 23))
self.menubar.setObjectName(“menubar”)
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName(“statusbar”)
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.JTTC.setText(_translate("MainWindow", ">家庭套餐:"))
self.SRTC.setText(_translate("MainWindow", "三人套餐"))
self.WRTC.setText(_translate("MainWindow", "五人套餐"))
self.T_Price1.setText(_translate("MainWindow", "120.0元/份"))
self.T_Price2.setText(_translate("MainWindow", "200.0元/份"))
self.Tjoin.setText(_translate("MainWindow", "加入清单"))
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class ZJM(object):
def setupUi(self,MainWindow):
MainWindow.setObjectName(“MainWindow”)
MainWindow.resize(780, 585)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName(“centralwidget”)
self.KIND = QtWidgets.QComboBox(self.centralwidget)
self.KIND.setGeometry(QtCore.QRect(30, 380, 251, 22))
self.KIND.setObjectName(“kind”)
self.KIND.addItem("")
self.KIND.addItem("")
self.KIND.addItem("")
self.KIND.addItem("")
self.KIND.addItem("")
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setGeometry(QtCore.QRect(340, 30, 431, 281))
self.tableWidget.setObjectName(“tableWidget”)
self.tableWidget.setColumnCount(4)
self.tableWidget.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(3, item)
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(590, 330, 51, 21))
self.label.setObjectName(“label”)
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(650, 330, 113, 20))
self.lineEdit.setObjectName(“lineEdit”)
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(390, 330, 71, 20))
self.label_2.setObjectName(“label_2”)
self.spinBox = QtWidgets.QSpinBox(self.centralwidget)
self.spinBox.setGeometry(QtCore.QRect(480, 330, 42, 22))
self.spinBox.setObjectName(“spinBox”)
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(460, 380, 51, 23))
self.pushButton_2.setObjectName(“pushButton_2”)
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(390, 380, 51, 23))
self.pushButton_3.setObjectName(“pushButton_3”)
self.kfcBack = QtWidgets.QLabel(self.centralwidget)
self.kfcBack.setGeometry(QtCore.QRect(40, 40, 261, 271))
self.kfcBack.setObjectName(“kfcBack”)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 780, 23))
self.menubar.setObjectName(“menubar”)
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName(“statusbar”)
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.KIND.setItemText(0, _translate("MainWindow", "选择餐品")) self.KIND.setItemText(1, _translate("MainWindow", "最新活动")) self.KIND.setItemText(2, _translate("MainWindow", "汉堡/主食")) self.KIND.setItemText(3, _translate("MainWindow", "咖啡/茶/饮料")) self.KIND.setItemText(4, _translate("MainWindow", "家庭套餐")) item = self.tableWidget.horizontalHeaderItem(0) item.setText(_translate("MainWindow", "餐品名")) item = self.tableWidget.horizontalHeaderItem(1) item.setText(_translate("MainWindow", "数量")) item = self.tableWidget.horizontalHeaderItem(2) item.setText(_translate("MainWindow", "单价")) item = self.tableWidget.horizontalHeaderItem(3) item.setText(_translate("MainWindow", "金额")) self.label.setText(_translate("MainWindow", " 合计:")) self.label_2.setText(_translate("MainWindow", "10元优惠卷")) self.pushButton_2.setText(_translate("MainWindow", "结算")) self.pushButton_3.setText(_translate("MainWindow", "删除")) self.kfcBack.setText(_translate("MainWindow", "TextLabel"))
from kfc import * from Jiatintaocan import * from Zhushi import * from HUODON import * from YinLiaoTianPing import * from PyQt5.QtCore import Qt import sys class KFCDC(QMainWindow,ZJM): def __init__(self): self.flag1=0 self.flag2=0 self.flag3=0 self.flag=0 self.mealName='鸡翅' self.quanTity=10 self.unitPrice=10 self.moNey=10 super(KFCDC, self).__init__() self.setupUi(self) self.child1=ActivityPackage() self.child2=Main_Food() self.child3=DrInk() self.child4=FaMily() self.KIND.currentIndexChanged.connect(self.Show) self.kfcBack.setPixmap(QtGui.QPixmap('./image/back.jpg')) self.kfcBack.setScaledContents(True) def Show(self): # self.KIND.currentIndexChanged(SELECT.select) if self.KIND.currentText() == '最新活动': self.child1.show() elif self.KIND.currentText() == '汉堡/主食': self.child2.show() elif self.KIND.currentText() == '咖啡/茶/饮料': self.child3.show() elif self.KIND.currentText() == '家庭套餐': self.child4.show() def QSS1(self,name,quantity,price,amount): self.Meal_Name = QTableWidgetItem(name) self.Meal_Name.setTextAlignment(Qt.AlignCenter) self.Quan_Tity = QTableWidgetItem(str(quantity)) self.Quan_Tity.setTextAlignment(Qt.AlignCenter) self.Unit_Price = QTableWidgetItem(str(price)) self.Unit_Price.setTextAlignment(Qt.AlignCenter) self.Sum_Money = QTableWidgetItem(str(amount)) self.Sum_Money.setTextAlignment(Qt.AlignCenter) # self.flag = self.flag + 1 self.Add(self.Meal_Name,self.Quan_Tity,self.Unit_Price,self.Sum_Money) print(self.Quan_Tity.text()) # def QSS2(self, name, quantity, price, amount): self.Meal_Name = QTableWidgetItem(name) self.Meal_Name.setTextAlignment(Qt.AlignCenter) self.Quan_Tity = QTableWidgetItem(str(quantity)) self.Quan_Tity.setTextAlignment(Qt.AlignCenter) self.Unit_Price = QTableWidgetItem(str(price)) self.Unit_Price.setTextAlignment(Qt.AlignCenter) self.Sum_Money = QTableWidgetItem(str(amount)) self.Sum_Money.setTextAlignment(Qt.AlignCenter) # self.flag = self.flag + 1 # self.Add(self.Meal_Name, self.Quan_Tity, self.Unit_Price, self.Sum_Money) self.flag2 = self.flag2 + 1 def QSS3(self, name, quantity, price, amount): Meal_Name = QTableWidgetItem(name) Meal_Name.setTextAlignment(Qt.AlignCenter) Quan_Tity = QTableWidgetItem(str(quantity)) Quan_Tity.setTextAlignment(Qt.AlignCenter) Unit_Price = QTableWidgetItem(str(price)) Unit_Price.setTextAlignment(Qt.AlignCenter) Sum_Money = QTableWidgetItem(str(amount)) Sum_Money.setTextAlignment(Qt.AlignCenter) self.flag3 = self.flag3 + 1 def LiSt(self): self.tableWidget.setItem(0, 0, self.Meal_Name) self.tableWidget.setItem(0, 1, self.Quan_Tity) self.tableWidget.setItem(0, 2, self.Unit_Price) self.tableWidget.setItem(0, 3, self.Sum_Money) def Add(self,Meal_Name, Quan_Tity, Unit_Price,Sum_Money): self.Rowcont = self.tableWidget.rowCount() if(self.flag1==0): self.tableWidget.insertRow(self.Rowcont) self.tableWidget.setItem(self.Rowcont, 0, Meal_Name) self.tableWidget.setItem(self.Rowcont, 1, Quan_Tity) self.tableWidget.setItem(self.Rowcont, 2, Unit_Price) self.tableWidget.setItem(self.Rowcont, 3, Sum_Money) self.flag1 = self.flag1 + 1 return self.flag1 elif(self.flag1==1): # print(self.flag1) # self.self.Rowcont = self.tableWidget.rowCount() for i in range(self.Rowcont): if(self.tableWidget.item(0,0).text()==Meal_Name): self.Rowcont = self.tableWidget.rowCount() self.tableWidget.setItem(self.Rowcont, 0, Meal_Name) self.tableWidget.setItem(self.Rowcont, 1, Quan_Tity) self.tableWidget.setItem(self.Rowcont, 2, Unit_Price) self.tableWidget.setItem(self.Rowcont, 3, Sum_Money) class ActivityPackage(QMainWindow,HD): def __init__(self): super(ActivityPackage, self).__init__() self.setupUi(self) self.HZJPJ.setPixmap(QtGui.QPixmap('./image/啤酒鸡翅.jpg')) self.HZJPJ.setScaledContents(True) self.HWSJ.setPixmap(QtGui.QPixmap('./image/万圣节限定.jpg')) self.HWSJ.setScaledContents(True) self.HJCTZ.setPixmap(QtGui.QPixmap('./image/限定活动.jpg')) self.HJCTZ.setScaledContents(True) self.Meal_Name1='啤酒鸡翅' self.Meal_Name2 = '翅桶' self.Meal_Name3 = '万圣节' self.Chicken_Price=115.0 self.Wings_Price=80.0 self.Halloween=100.0 self.HOrder1.valueChanged.connect(self.Add1) self.HOrder2.valueChanged.connect(self.Add2) self.HOrder3.valueChanged.connect(self.Add3) self.HJoin.clicked.connect(self.H_JOIN) def Add1(self): self.QuanTity1=self.HOrder1.value() self.Amount1 = self.Chicken_Price * self.QuanTity1 # print(self.QuanTity1) kfdc.QSS1(self.Meal_Name1, self.QuanTity1, self.Chicken_Price, self.Amount1) # return self.QuanTity1,self.Amount1 def Add2(self): self.QuanTity2 = self.HOrder2.value() self.Amount2 = self.Wings_Price * self.QuanTity2 kfdc.QSS2(self.Meal_Name2, self.QuanTity2, self.Wings_Price, self.Amount2) return self.QuanTity2, self.Amount2 def Add3(self): self.QuanTity3= self.HOrder3.value() self.Amount3 = self.Halloween * self.QuanTity3 kfdc.QSS3(self.Meal_Name3, self.QuanTity3, self.Halloween, self.Amount3) return self.QuanTity3, self.Amount3 def Price(self): return self.Amount1,self.Amount2,self.Amount3 def H_JOIN(self): print(self.Meal_Name1) print(self.QuanTity1) print(self.Chicken_Price) print(self.Amount1) class Main_Food(QMainWindow,ZS): def __init__(self): super(Main_Food, self).__init__() self.setupUi(self) # self.SELEC. def shod(self): # self.aa=SELECT() self.aa.show() class DrInk(QMainWindow, YL): def __init__(self): super(DrInk, self).__init__() self.setupUi(self) # self.SELEC. def shod(self): # self.aa = SELECT() self.aa.show() class FaMily(QMainWindow, JT): def __init__(self): super(FaMily, self).__init__() self.setupUi(self) # self.SELEC. def shod(self): self.aa.show() if __name__ == '__main__': app = QApplication(sys.argv) MainWindow = QMainWindow() kfdc=KFCDC() kfdc.show() sys.exit(app.exec_())
总结:相对之前的程序来说,本次KFC点餐系统,覆盖面更广,我也遇到了很多困难,程序还有很多功能未能实现,还需要不断完善,下次完善了再重新发一次
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。