python+pyqt 5 KFC 주문 수납 시스템 구현
이 kfc 수납 시스템 에서 제 가 실현 한 다음 과 같은 기능:
1.정상 적 인 음식 결제 와 거스름돈.
2.기본 세트 결제 와 거스름돈.
3.혜택 을 이용 해 학 전갈 이 방 을 삐다 낙타 이각
4.일정 시간 동안 매장 내 이벤트 참여 가능
5.작은 표 인쇄 를 모 의 하 는 기능(파일 에 쓰기).
프로젝트 파일:
KFC.py 파일 은 각 기능,kfctip.txt 파일 을 실현 하여 작은 표를 인쇄 하고 picture 파일 에 인터페이스 에 필요 한 그림 을 저장 하 며 다른 네 개의 파일 은 각 인터페이스 레이아웃 입 니 다.
주 인터페이스:
정상 메뉴 주문 창:
정식 주문 창:
이벤트 세트 주문 창:
두 번 째 이벤트 세트 를 클릭 하면:
주문 가입 클릭 하여 반환 후 메 인 인터페이스 에서 주문 정 보 를 생 성 합 니 다:
클릭 하여 결제:
작은 표를 파일 로 인쇄 하기:
다음은 코드 구현:
인터페이스 레이아웃 모두 pyqt 5 사용
주 인터페이스 레이아웃:
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.pushButton_5.setObjectName("pushButton_5")
self.pushButton_6 = QtWidgets.QPushButton(Form)
self.pushButton_6.setGeometry(QtCore.QRect(260, 400, 93, 41))
self.pushButton_6.setObjectName("pushButton_6")
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(50, 170, 72, 15))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(30, 140, 121, 21))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(Form)
self.label_3.setGeometry(QtCore.QRect(30, 10, 121, 111))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Form)
self.label_4.setGeometry(QtCore.QRect(270, 170, 72, 15))
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(Form)
self.label_5.setGeometry(QtCore.QRect(270, 140, 72, 15))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(Form)
self.label_6.setGeometry(QtCore.QRect(240, 10, 131, 111))
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(Form)
self.label_7.setGeometry(QtCore.QRect(490, 170, 72, 15))
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(Form)
self.label_8.setGeometry(QtCore.QRect(480, 140, 91, 16))
self.label_8.setObjectName("label_8")
self.label_9 = QtWidgets.QLabel(Form)
self.label_9.setGeometry(QtCore.QRect(460, 10, 131, 111))
self.label_9.setObjectName("label_9")
self.label_10 = QtWidgets.QLabel(Form)
self.label_10.setGeometry(QtCore.QRect(50, 380, 72, 15))
self.label_10.setObjectName("label_10")
self.label_11 = QtWidgets.QLabel(Form)
self.label_11.setGeometry(QtCore.QRect(60, 360, 51, 16))
self.label_11.setObjectName("label_11")
self.label_12 = QtWidgets.QLabel(Form)
self.label_12.setGeometry(QtCore.QRect(30, 250, 121, 101))
self.label_12.setObjectName("label_12")
self.label_13 = QtWidgets.QLabel(Form)
self.label_13.setGeometry(QtCore.QRect(270, 380, 72, 15))
self.label_13.setObjectName("label_13")
self.label_14 = QtWidgets.QLabel(Form)
self.label_14.setGeometry(QtCore.QRect(250, 360, 131, 16))
self.label_14.setObjectName("label_14")
self.label_15 = QtWidgets.QLabel(Form)
self.label_15.setGeometry(QtCore.QRect(240, 250, 131, 101))
self.label_15.setObjectName("label_15")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", " "))
self.pushButton_2.setText(_translate("Form", " "))
self.pushButton_3.setText(_translate("Form", " "))
self.pushButton_4.setText(_translate("Form", " "))
self.pushButton_5.setText(_translate("Form", " "))
self.pushButton_6.setText(_translate("Form", " "))
self.label.setText(_translate("Form", " 1"))
self.label_2.setText(_translate("Form", " "))
self.label_3.setText(_translate("Form", "TextLabel"))
self.label_4.setText(_translate("Form", " 2"))
self.label_5.setText(_translate("Form", " "))
self.label_6.setText(_translate("Form", "TextLabel"))
self.label_7.setText(_translate("Form", " 3"))
self.label_8.setText(_translate("Form", " "))
self.label_9.setText(_translate("Form", "TextLabel"))
self.label_10.setText(_translate("Form", " 4"))
self.label_11.setText(_translate("Form", " "))
self.label_12.setText(_translate("Form", "TextLabel"))
self.label_13.setText(_translate("Form", " 5"))
self.label_14.setText(_translate("Form", " ( )"))
self.label_15.setText(_translate("Form", "TextLabel"))
정식 화면:
from PyQt5 import QtCore, QtWidgets
class Ui_Package(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(728, 393)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(90, 280, 91, 31))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(340, 280, 93, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(100, 250, 72, 15))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(350, 250, 72, 15))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(Form)
self.label_3.setGeometry(QtCore.QRect(80, 220, 131, 21))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Form)
self.label_4.setGeometry(QtCore.QRect(330, 220, 111, 21))
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(Form)
self.label_5.setGeometry(QtCore.QRect(60, 20, 161, 171))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(Form)
self.label_6.setGeometry(QtCore.QRect(300, 20, 171, 171))
self.label_6.setObjectName("label_6")
self.pushButton_3 = QtWidgets.QPushButton(Form)
self.pushButton_3.setGeometry(QtCore.QRect(560, 280, 101, 41))
self.pushButton_3.setObjectName("pushButton_3")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", " "))
self.pushButton_2.setText(_translate("Form", " "))
self.label.setText(_translate("Form", " 1"))
self.label_2.setText(_translate("Form", " 2"))
self.label_3.setText(_translate("Form", " "))
self.label_4.setText(_translate("Form", " "))
self.label_5.setText(_translate("Form", "TextLabel"))
self.label_6.setText(_translate("Form", "TextLabel"))
self.pushButton_3.setText(_translate("Form", " "))
이벤트 인터페이스:
from PyQt5 import QtCore, QtWidgets
class Ui_Activity(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(639, 335)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(50, 240, 93, 31))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(300, 240, 93, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(11, 220, 201, 20))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(20, 200, 161, 16))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(Form)
self.label_3.setGeometry(QtCore.QRect(50, 180, 91, 16))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Form)
self.label_4.setGeometry(QtCore.QRect(30, 30, 141, 141))
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(Form)
self.label_5.setGeometry(QtCore.QRect(261, 220, 201, 20))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(Form)
self.label_6.setGeometry(QtCore.QRect(270, 200, 161, 16))
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(Form)
self.label_7.setGeometry(QtCore.QRect(310, 180, 61, 16))
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(Form)
self.label_8.setGeometry(QtCore.QRect(280, 30, 151, 141))
self.label_8.setObjectName("label_8")
self.pushButton_3 = QtWidgets.QPushButton(Form)
self.pushButton_3.setGeometry(QtCore.QRect(490, 250, 101, 31))
self.pushButton_3.setObjectName("pushButton_3")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", " "))
self.pushButton_2.setText(_translate("Form", " "))
self.label.setText(_translate("Form", " 1"))
self.label_2.setText(_translate("Form", "2018.10.1-2018.10.31"))
self.label_3.setText(_translate("Form", " 5 "))
self.label_4.setText(_translate("Form", "TextLabel"))
self.label_5.setText(_translate("Form", " 2"))
self.label_6.setText(_translate("Form", "2018.11.1-2018.11.11"))
self.label_7.setText(_translate("Form", " "))
self.label_8.setText(_translate("Form", "TextLabel"))
self.pushButton_3.setText(_translate("Form", " "))
다음은 각 인터페이스의 상호 연결 과 각 기능 의 실현 을 실현 하기 위 한 것 이다.
# -*- coding: utf-8 -*-
# :dcjmessi
# :2018/10/19
from kfcmain import *
from normal import *
from package import *
from activity import *
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QPixmap
class KFC_Main(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.main_ui = Ui_MainWindow()
self.main_ui.setupUi(self)
#
btn_del = self.main_ui.pushButton_5
btn_del.clicked.connect(self.order_del)
btn_num = self.main_ui.pushButton_6
btn_num.clicked.connect(self.order_num)
self.btn_tip = self.main_ui.pushButton_7
self.btn_tip.clicked.connect(self.order_tip)
#
self.btn_tip.setEnabled(False)
#
self.num = []
self.new_num = []
#
def person(self):
#
self.main_ui.label_8.setPixmap(QPixmap('./picture/ .png'))
#
self.main_ui.label_8.setScaledContents(True)
#
self.balance = 200
#
self.coupons = 1
#
self.main_ui.label_2.setText(str(self.balance))
self.main_ui.label_5.setText(str(self.coupons))
#
kfcmain.show()
# tableWidget
def order_del(self):
#
row_index = kfcmain.main_ui.tableWidget.currentRow()
if row_index != -1:
#
kfcmain.main_ui.tableWidget.removeRow(row_index)
#
def order_num(self):
#
self.btn_tip.setEnabled(True)
#
for row_index in range(kfcmain.main_ui.tableWidget.rowCount()):
# num
self.num.append(kfcmain.main_ui.tableWidget.item(row_index, 2).text())
# num int
self.new_num = eval('[' + (','.join(self.num)) + ']')
# new_num
self.money = sum(self.new_num)
#
if self.coupons >= 1:
#
button = QMessageBox.information(self, " ", " ", QMessageBox.Yes | QMessageBox.No)
#
if button == QMessageBox.Yes:
#
self.coupons = self.coupons -1
self.main_ui.label_5.setText(str(self.coupons))
#
if self.balance >= (self.money - self.coupons * 20):
QMessageBox.information(self, " ", " !", QMessageBox.Yes)
self.balance = self.balance - self.money - self.coupons * 20
self.main_ui.label_2.setText(str(self.balance))
else:
QMessageBox.information(self, " ", " !", QMessageBox.Yes)
#
else:
if self.balance >= self.money:
QMessageBox.information(self, " ", " !", QMessageBox.Yes)
self.balance = self.balance - self.money
self.main_ui.label_2.setText(str(self.balance))
else:
QMessageBox.information(self, " ", " !", QMessageBox.Yes)
#
else:
if self.balance >= self.money:
QMessageBox.information(self, " ", " !", QMessageBox.Yes)
self.balance = self.balance - self.money
self.main_ui.label_2.setText(str(self.balance))
else:
QMessageBox.information(self, " ", " !", QMessageBox.Yes)
#
def order_tip(self):
# txt
with open("kfctip.txt", "w") as f:
#
for row_index in range(kfcmain.main_ui.tableWidget.rowCount()):
#
for column_index in range(kfcmain.main_ui.tableWidget.columnCount()):
# tableWidget
f.write(kfcmain.main_ui.tableWidget.item(row_index, column_index).text() + "
")
f.write(" :" + str(self.money) + " ")
f.close()
class Normal(QWidget):
def __init__(self):
QWidget.__init__(self)
self.normal_ui = Ui_Normal()
self.normal_ui.setupUi(self)
#
self.bt1 = 0
self.bt2 = 0
self.bt3 = 0
self.bt4 = 0
self.bt6 = 0
#
self.bt5 = 0
#
btn_hamburg = self.normal_ui.pushButton
btn_hamburg.clicked.connect(self.order_hamburg)
btn_chicken = self.normal_ui.pushButton_2
btn_chicken.clicked.connect(self.order_chicken)
btn_fries = self.normal_ui.pushButton_3
btn_fries.clicked.connect(self.order_fries)
btn_tea = self.normal_ui.pushButton_4
btn_tea.clicked.connect(self.order_tea)
btn_ice = self.normal_ui.pushButton_6
btn_ice.clicked.connect(self.order_ice)
btn_return = self.normal_ui.pushButton_5
btn_return.clicked.connect(self.nor_show)
#
def nor_order(self):
self.normal_ui.label_3.setPixmap(QPixmap('./picture/ .png'))
self.normal_ui.label_3.setScaledContents(True)
self.normal_ui.label_6.setPixmap(QPixmap('./picture/ .png'))
self.normal_ui.label_6.setScaledContents(True)
self.normal_ui.label_9.setPixmap(QPixmap('./picture/ .png'))
self.normal_ui.label_9.setScaledContents(True)
self.normal_ui.label_12.setPixmap(QPixmap('./picture/ .png'))
self.normal_ui.label_12.setScaledContents(True)
self.normal_ui.label_15.setPixmap(QPixmap('./picture/ .png'))
self.normal_ui.label_15.setScaledContents(True)
#
self.price_hamburg = 18.5
self.price_chicken = 11.0
self.price_fries = 13.0
self.price_tea = 13.5
self.price_ice = 10.0
#
self.normal_ui.label.setText(str(self.price_hamburg)+" / ")
self.normal_ui.label_4.setText(str(self.price_chicken)+" / ")
self.normal_ui.label_7.setText(str(self.price_fries)+" / ")
self.normal_ui.label_10.setText(str(self.price_tea)+" / ")
self.normal_ui.label_13.setText(str(self.price_ice)+" / ")
normal.show()
#
def order_hamburg(self):
self.bt1 += 1
def order_chicken(self):
self.bt2 += 1
def order_fries(self):
self.bt3 += 1
def order_tea(self):
self.bt4 += 1
def order_ice(self):
self.bt6 += 1
def nor_show(self):
self.bt5 += 1
#
normal.hide()
#
self.num_hamburg = self.price_hamburg * self.bt1
self.num_chicken = self.price_chicken * self.bt2
self.num_fries = self.price_fries * self.bt3
self.num_tea = self.price_tea * self.bt4
self.num_ice = self.price_ice * self.bt6
#
if self.bt5 > 1:
for row_index in range(kfcmain.main_ui.tableWidget.rowCount()):
# tableWidget , name
name.append(kfcmain.main_ui.tableWidget.item(row_index, 0).text())
if ' ' in name:
#
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 2, QTableWidgetItem(str(self.num_hamburg)))
if ' ' not in name:
#
if self.bt1 != 0:
#
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_2.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_hamburg)))
if ' ' in name:
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 1, QTableWidgetItem("×" + str(self.bt2)))
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 2, QTableWidgetItem(str(self.num_chicken)))
if ' ' not in name:
if self.bt2 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_5.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_chicken)))
if ' ' in name:
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 1, QTableWidgetItem("×" + str(self.bt3)))
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 2, QTableWidgetItem(str(self.num_fries)))
if ' ' not in name:
if self.bt3 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_8.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt3)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_fries)))
if ' 'in name:
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 1, QTableWidgetItem("×" + str(self.bt4)))
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 2, QTableWidgetItem(str(self.num_tea)))
if ' ' not in name:
if self.bt4 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_11.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt4)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_tea)))
if ' ( )' in name:
kfcmain.main_ui.tableWidget.setItem(name.index(' ( )'), 1, QTableWidgetItem("×" + str(self.bt6)))
kfcmain.main_ui.tableWidget.setItem(name.index(' ( )'), 2, QTableWidgetItem(str(self.num_ice)))
if ' ( )' not in name:
if self.bt6 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_14.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt6)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_ice)))
#
else:
if self.bt1 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_2.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_hamburg)))
if self.bt2 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_5.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_chicken)))
if self.bt3 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_8.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt3)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_fries)))
if self.bt4 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_11.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt4)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_tea)))
if self.bt6 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_14.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt6)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_ice)))
class Package(QWidget):
def __init__(self):
QWidget.__init__(self)
self.package_ui = Ui_Package()
self.package_ui.setupUi(self)
#
self.bt1 = 0
self.bt2 = 0
#
self.bt3 = 0
#
btn_pack1 = self.package_ui.pushButton
btn_pack1.clicked.connect(self.order_pack1)
btn_pack2 = self.package_ui.pushButton_2
btn_pack2.clicked.connect(self.order_pack2)
btn_return = self.package_ui.pushButton_3
btn_return.clicked.connect(self.pac_show)
#
def pac_order(self):
self.package_ui.label_5.setPixmap(QPixmap('./picture/ 2.png'))
self.package_ui.label_5.setScaledContents(True)
self.package_ui.label_6.setPixmap(QPixmap('./picture/ 1.png'))
self.package_ui.label_6.setScaledContents(True)
#
self.price_pack1 = 89.0
self.price_pack2 = 67.0
self.package_ui.label.setText(str(self.price_pack1)+" / ")
self.package_ui.label_2.setText(str(self.price_pack2)+" / ")
package.show()
def order_pack1(self):
self.bt1 += 1
def order_pack2(self):
self.bt2 += 1
def pac_show(self):
self.bt3 += 1
package.hide()
self.num_pack1 = self.price_pack1 * self.bt1
self.num_pack2 = self.price_pack2 * self.bt2
if self.bt3 > 1:
for row_index in range(kfcmain.main_ui.tableWidget.rowCount()):
name.append(kfcmain.main_ui.tableWidget.item(row_index, 0).text())
if ' ' in name:
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 2, QTableWidgetItem(str(self.num_pack1)))
if ' ' not in name:
if self.bt1 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_3.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_pack1)))
if ' ' in name:
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 1, QTableWidgetItem("×" + str(self.bt2)))
kfcmain.main_ui.tableWidget.setItem(name.index(' '), 2, QTableWidgetItem(str(self.num_pack2)))
if ' ' not in name:
if self.bt2 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_4.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_pack2)))
else:
if self.bt1 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_3.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_pack1)))
if self.bt2 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_4.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_pack2)))
class Activity(QWidget):
def __init__(self):
QWidget.__init__(self)
self.activity_ui = Ui_Activity()
self.activity_ui.setupUi(self)
#
self.bt1 = 0
#
self.bt3 = 0
#
btn_act1 = self.activity_ui.pushButton
btn_act1.clicked.connect(self.order_act1)
btn_act2 = self.activity_ui.pushButton_2
btn_act2.clicked.connect(self.order_act2)
btn_return = self.activity_ui.pushButton_3
btn_return.clicked.connect(self.act_show)
def act_order(self):
self.activity_ui.label_4.setPixmap(QPixmap('./picture/ 1.png'))
self.activity_ui.label_4.setScaledContents(True)
self.activity_ui.label_8.setPixmap(QPixmap('./picture/ 2.png'))
self.activity_ui.label_8.setScaledContents(True)
#
self.price_act1 = 29.0
self.price_act2 = 69.0
self.activity_ui.label.setText(str(self.price_act1) + " / :"+str(self.price_act1 + 7) + " / ")
self.activity_ui.label_5.setText(str(self.price_act2) + " / :"+str(self.price_act2 + 10) + " / ")
activity.show()
def order_act1(self):
self.bt1 += 1
def order_act2(self):
QMessageBox.information(self, " ", " , !", QMessageBox.Yes)
def act_show(self):
self.bt3 += 1
activity.hide()
self.num_act1 = self.price_act1 * self.bt1
if self.bt3 > 1:
for row_index in range(kfcmain.main_ui.tableWidget.rowCount()):
name.append(kfcmain.main_ui.tableWidget.item(row_index, 0).text())
if ' 5 ' in name:
kfcmain.main_ui.tableWidget.setItem(name.index(' 5 '), 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(name.index(' 5 '), 2, QTableWidgetItem(str(self.num_act1)))
if ' 5 ' not in name:
if self.bt1 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(activity.activity_ui.label_3.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_act1)))
else:
if self.bt1 != 0:
row_count = kfcmain.main_ui.tableWidget.rowCount()
kfcmain.main_ui.tableWidget.insertRow(row_count)
kfcmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(activity.activity_ui.label_3.text()))
kfcmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
kfcmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_act1)))
if __name__=="__main__":
app = QApplication(sys.argv)
kfcmain = KFC_Main()
normal = Normal()
package = Package()
activity = Activity()
#
kfcmain.person()
#
btn_normal = kfcmain.main_ui.pushButton_2
btn_normal.clicked.connect(normal.nor_order)
btn_package = kfcmain.main_ui.pushButton_3
btn_package.clicked.connect(package.pac_order)
btn_activity = kfcmain.main_ui.pushButton_4
btn_activity.clicked.connect(activity.act_order)
# name
name = []
sys.exit(app.exec_())
삭 제 는 동 식 품 주문 에서 만 삭 제 됐 을 뿐 수량 감 소 는 이 뤄 지지 않 아 자체 적 으로 추가 할 수 있다.더 많은 학습 자 료 는 주제 인 에 주목 하 세 요.
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.