本文实例为大家分享了python实现KFC点餐收银系统的具体代码,供大家参考,具体内容如下
这个kfc收银系统我实现了的以下功能:
1.正常餐品结算和找零。
2.基本套餐结算和找零。
3.使用优惠劵购买餐品结算和找零。
4.可在一定时间段参与店内活动
5.模拟打印小票的功能(写到文件中)。
工程文件:
肯德基.py文件实现各功能、kfctip.txt文件用于打印小票、picture文件里存放界面所需的图片、其他四个文件为各界面布局。
主界面:
正常餐品点餐界面:
套餐点餐界面:
活动套餐点餐界面:
当点击第二个活动套餐时:
加入订单点击返回后主界面会生成订单信息:
点击结算:
打印小票到文件:
以下是代码实现:
界面布局均使用pyqt5
主界面布局:
from PyQt5 import QtCore, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(893, 489)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(510, 20, 101, 41))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(510, 80, 101, 41))
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_4.setGeometry(QtCore.QRect(510, 140, 101, 41))
self.pushButton_4.setObjectName("pushButton_4")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(510, 200, 111, 21))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(510, 230, 72, 15))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(590, 230, 21, 16))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(510, 260, 81, 21))
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(510, 290, 72, 15))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(590, 290, 21, 16))
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(640, 20, 61, 21))
self.label_7.setObjectName("label_7")
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setGeometry(QtCore.QRect(640, 40, 241, 231))
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(3)
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)
self.tableWidget.horizontalHeader().setDefaultSectionSize(70)
self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_5.setGeometry(QtCore.QRect(640, 290, 71, 31))
self.pushButton_5.setObjectName("pushButton_5")
self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_6.setGeometry(QtCore.QRect(640, 350, 91, 31))
self.pushButton_6.setObjectName("pushButton_6")
self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_7.setGeometry(QtCore.QRect(750, 350, 91, 31))
self.pushButton_7.setObjectName("pushButton_7")
self.label_8 = QtWidgets.QLabel(self.centralwidget)
self.label_8.setGeometry(QtCore.QRect(10, 10, 481, 431))
self.label_8.setObjectName("label_8")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 893, 26))
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", "肯德基"))
self.pushButton_2.setText(_translate("MainWindow", "基本餐"))
self.pushButton_3.setText(_translate("MainWindow", "套餐"))
self.pushButton_4.setText(_translate("MainWindow", "活动"))
self.label.setText(_translate("MainWindow", "会员储值卡余额"))
self.label_2.setText(_translate("MainWindow", "钱"))
self.label_3.setText(_translate("MainWindow", "元"))
self.label_4.setText(_translate("MainWindow", "您的优惠券"))
self.label_5.setText(_translate("MainWindow", "券"))
self.label_6.setText(_translate("MainWindow", "张"))
self.label_7.setText(_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", "价格/元"))
self.pushButton_5.setText(_translate("MainWindow", "删除"))
self.pushButton_6.setText(_translate("MainWindow", "结算"))
self.pushButton_7.setText(_translate("MainWindow", "打印小票"))
self.label_8.setText(_translate("MainWindow", "图"))
正常套餐界面:
from PyQt5 import QtCore, QtWidgets
class Ui_Normal(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(728, 459)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(40, 190, 93, 41))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(260, 190, 93, 41))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(Form)
self.pushButton_3.setGeometry(QtCore.QRect(480, 190, 93, 41))
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_4 = QtWidgets.QPushButton(Form)
self.pushButton_4.setGeometry(QtCore.QRect(40, 400, 93, 41))
self.pushButton_4.setObjectName("pushButton_4")
self.pushButton_5 = QtWidgets.QPushButton(Form)
self.pushButton_5.setGeometry(QtCore.QRect(620, 400, 93, 41))
self.pushBu