当前位置:   article > 正文

实战Python:利用Python和PyQt5实现瑞幸咖啡点餐系统_瑞幸抢单脚本

瑞幸抢单脚本

总结

程序设计方法学,最后要求做一个咖啡点餐系统。之前学过QT,又临时突击了几天PyQt借鉴网上的代码,没有用到数据库之类麻烦的东西,只是几个界面的交互。代码比较简单。
其实我感觉整体代码难度不大,PyQt5中文教程我很快的过了一遍基本上所有的代码都能读懂了,我在原有基础上只加了一个删除的操作。原本还想加点别的,实在时间有限,马上就交作业了,加上导师项目催得紧,只能改一改加一点功能了。过段时间有时间会把这个再完善一下。

实现了以下功能:

  1. 基本餐品、套餐、活动三个界面的餐品的的选择
  2. 主界面订单的显示、删除某一样餐品、减少某一样餐品的购买量
  3. 订单的结算
  4. 打印小票
  5. 储值卡和优惠卷的使用

共包括以下文件:

在这里插入图片描述
其中,acticity.py、luckinmain.py、normal.py、setmeal.py分别为不同页面的布局设置文件,luckin.main为主程序界面,实现各个功能的调用。

程序界面

主界面:

在这里插入图片描述

基本餐界面:

在这里插入图片描述

套餐界面:

在这里插入图片描述

活动界面:

在这里插入图片描述

点餐完成后,可以回到主界面进行餐品的删除或减少(马上交作业,时间有限,减少只写了基本餐的减少)

在这里插入图片描述

活动界面如果不在活动内会弹出消息盒子提示:

在这里插入图片描述

页面布局控件

在这里插入图片描述

完整代码

luckin.py

# 作者:KaiSarH
# 日期:2019/11/4
from luckinmain import *
from normal import *
from setmeal import *
from activity import *
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QPixmap

class Luckin_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_delone = self.main_ui.pushButton_8
        btn_delone.clicked.connect(self.order_decline)
        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 = 500
        # 初始化优惠券数量
        self.coupons = 1
        # 显示余额和券数量
        self.main_ui.label_2.setText(str(self.balance))
        self.main_ui.label_5.setText(str(self.coupons))
        # 显示主界面
        luckinmain.show()

    # 删除操作——直接删除一行
    def order_del(self):
        # 获取所选行索引
        row_index = luckinmain.main_ui.tableWidget.currentRow()
        if row_index != -1:
            # 删除
            luckinmain.main_ui.tableWidget.removeRow(row_index)

    # 删除操作——删除某一种商品一份
    def order_decline(self):
        self.price_Cappuccino = 18.5
        self.price_Latte = 11.0
        self.price_Mocha = 13.0
        self.price_Americano = 13.5
        self.price_Macchiato = 10.0
        # 获取当前所选的行
        current_row = luckinmain.main_ui.tableWidget.currentRow()
        # 将字符串转换为整型
        num = luckinmain.main_ui.tableWidget.item(current_row, 1).text()
        num = eval(num.replace(num[0], ''))
        # 判断是否大于1
        if num == 1:
            # 等于1的话直接删除
            luckinmain.main_ui.tableWidget.removeRow(current_row)
        else:
            # 大于1则进行判断 修改数量和价格
            num -= 1
            kind = luckinmain.main_ui.tableWidget.item(current_row, 0).text()
            luckinmain.main_ui.tableWidget.setItem(current_row, 1, QTableWidgetItem("×" + str(num)))
            if kind == '卡布奇诺':
                luckinmain.main_ui.tableWidget.setItem(current_row, 2,
                                                       QTableWidgetItem(str(self.price_Cappuccino * num)))
            elif kind == '拿铁':
                luckinmain.main_ui.tableWidget.setItem(current_row, 2,
                                                       QTableWidgetItem(str(self.price_Latte * num)))
            elif kind == '摩卡':
                luckinmain.main_ui.tableWidget.setItem(current_row, 2,
                                                       QTableWidgetItem(str(self.price_Mocha * num)))
            elif kind == '标准美式':
                luckinmain.main_ui.tableWidget.setItem(current_row, 2,
                                                       QTableWidgetItem(str(self.price_Americano * num)))
            elif kind == '焦糖玛奇朵':
                luckinmain.main_ui.tableWidget.setItem(current_row, 2,
                                                       QTableWidgetItem(str(self.price_Macchiato * num)))

    # 结算
    def order_num(self):
        # 设置打印小票按钮为可用
        self.btn_tip.setEnabled(True)
        # 遍历所有行
        for row_index in range(luckinmain.main_ui.tableWidget.rowCount()):
            # 将每一行的第三项值(数量)添加到num列表里
            self.num.append(luckinmain.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))
                # 余额足够 一张优惠卷为20元
                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("luckinbill.txt", "w") as f:
            # 遍历行
            for row_index in range(luckinmain.main_ui.tableWidget.rowCount()):
                # 遍历列
                for column_index in range(luckinmain.main_ui.tableWidget.columnCount()):
                    # 将tableWidget数据写入文件
                    f.write(luckinmain.main_ui.tableWidget.item(row_index, column_index).text() + "\n")
            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_Cappuccino = self.normal_ui.pushButton
        btn_Cappuccino.clicked.connect(self.order_Cappuccino)
        btn_Latte = self.normal_ui.pushButton_2
        btn_Latte.clicked.connect(self.order_Latte)
        btn_Mocha = self.normal_ui.pushButton_3
        btn_Mocha.clicked.connect(self.order_Mocha)
        btn_Americano = self.normal_ui.pushButton_4
        btn_Americano.clicked.connect(self.order_Americano)
        btn_ice = self.normal_ui.pushButton_5
        btn_ice.clicked.connect(self.order_ice)
        btn_return = self.normal_ui.pushButton_6
        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_Cappuccino = 18.5
        self.price_Latte = 11.0
        self.price_Mocha = 13.0
        self.price_Americano = 13.5
        self.price_Macchiato = 10.0
        # 显示价格
        self.normal_ui.label.setText(str(self.price_Cappuccino)+"元/份")
        self.normal_ui.label_4.setText(str(self.price_Latte)+"元/份")
        self.normal_ui.label_7.setText(str(self.price_Mocha)+"元/份")
        self.normal_ui.label_10.setText(str(self.price_Americano)+"元/份")
        self.normal_ui.label_13.setText(str(self.price_Macchiato)+"元/份")
        # 显示界面
        normal.show()

    # 计算不同餐品点击次数
    def order_Cappuccino(self):
        self.bt1 += 1

    def order_Latte(self):
        self.bt2 += 1

    def order_Mocha(self):
        self.bt3 += 1

    def order_Americano(self):
        self.bt4 += 1

    def order_ice(self):
        self.bt5 += 1

    def nor_show(self):
        self.bt6 += 1
        # 隐藏界面
        normal.hide()
        # 获取所选各基本餐的数量对应的价格
        self.num_Cappuccino = self.price_Cappuccino * self.bt1
        self.num_Latte = self.price_Latte * self.bt2
        self.num_Mocha = self.price_Mocha * self.bt3
        self.num_Americano = self.price_Americano * self.bt4
        self.num_Macchiato = self.price_Macchiato * self.bt6
        # 不是第一次进入该界面
        if self.bt6 > 1:
            for row_index in range(luckinmain.main_ui.tableWidget.rowCount()):
                # 获取tableWidget的所有名称,并放入name列表
                name.append(luckinmain.main_ui.tableWidget.item(row_index, 0).text())
            if '卡布奇诺' in name:
                # 重新设置该行的数量和价格
                luckinmain.main_ui.tableWidget.setItem(name.index('卡布奇诺'), 1, QTableWidgetItem("×" + str(self.bt1)))
                luckinmain.main_ui.tableWidget.setItem(name.index('卡布奇诺'), 2, QTableWidgetItem(str(self.num_Cappuccino)))
            if '卡布奇诺' not in name:
                # 已选择
                if self.bt1 != 0:
                    # 添加一行数据
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_2.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Cappuccino)))
            if '拿铁' in name:
                luckinmain.main_ui.tableWidget.setItem(name.index('拿铁'), 1, QTableWidgetItem("×" + str(self.bt2)))
                luckinmain.main_ui.tableWidget.setItem(name.index('拿铁'), 2, QTableWidgetItem(str(self.num_Latte)))
            if '拿铁' not in name:
                if self.bt2 != 0:
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_5.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Latte)))
            if '摩卡' in name:
                luckinmain.main_ui.tableWidget.setItem(name.index('摩卡'), 1, QTableWidgetItem("×" + str(self.bt3)))
                luckinmain.main_ui.tableWidget.setItem(name.index('摩卡'), 2, QTableWidgetItem(str(self.num_Mocha)))
            if '摩卡' not in name:
                if self.bt3 != 0:
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_8.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt3)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Mocha)))
            if '标准美式'in name:
                luckinmain.main_ui.tableWidget.setItem(name.index('标准美式'), 1, QTableWidgetItem("×" + str(self.bt4)))
                luckinmain.main_ui.tableWidget.setItem(name.index('标准美式'), 2, QTableWidgetItem(str(self.num_Americano)))
            if '标准美式' not in name:
                if self.bt4 != 0:
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_11.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt4)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Americano)))
            if '焦糖玛奇朵' in name:
                luckinmain.main_ui.tableWidget.setItem(name.index('焦糖玛奇朵'), 1, QTableWidgetItem("×" + str(self.bt6)))
                luckinmain.main_ui.tableWidget.setItem(name.index('焦糖玛奇朵'), 2, QTableWidgetItem(str(self.num_Macchiato)))
            if '焦糖玛奇朵' not in name:
                if self.bt5 != 0:
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_14.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt6)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Macchiato)))
        # 第一次进入该界面
        else:
            if self.bt1 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_2.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
                luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Cappuccino)))
            if self.bt2 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_5.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
                luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Latte)))
            if self.bt3 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_8.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt3)))
                luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Mocha)))
            if self.bt4 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_11.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt4)))
                luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Americano)))
            if self.bt5 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(normal.normal_ui.label_14.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt6)))
                luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_Macchiato)))

class Package(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.package_ui = Ui_Setmeal()
        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(luckinmain.main_ui.tableWidget.rowCount()):
                name.append(luckinmain.main_ui.tableWidget.item(row_index, 0).text())
            if '咖啡香茶外送套餐' in name:
                luckinmain.main_ui.tableWidget.setItem(name.index('咖啡香茶外送套餐'), 1, QTableWidgetItem("×" + str(self.bt1)))
                luckinmain.main_ui.tableWidget.setItem(name.index('咖啡香茶外送套餐'), 2, QTableWidgetItem(str(self.num_pack1)))
            if '咖啡香茶外送套餐' not in name:
                if self.bt1 != 0:
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_3.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_pack1)))
            if '咖啡冰淇淋套餐' in name:
                luckinmain.main_ui.tableWidget.setItem(name.index('咖啡冰淇淋套餐'), 1, QTableWidgetItem("×" + str(self.bt2)))
                luckinmain.main_ui.tableWidget.setItem(name.index('咖啡冰淇淋套餐'), 2, QTableWidgetItem(str(self.num_pack2)))
            if '咖啡冰淇淋套餐' not in name:
                if self.bt2 != 0:
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_4.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_pack2)))
        else:
            if self.bt1 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_3.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
                luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_pack1)))
            if self.bt2 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(package.package_ui.label_4.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt2)))
                luckinmain.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(luckinmain.main_ui.tableWidget.rowCount()):
                name.append(luckinmain.main_ui.tableWidget.item(row_index, 0).text())
            if '草莓芝士茶' in name:
                luckinmain.main_ui.tableWidget.setItem(name.index('草莓芝士茶'), 1, QTableWidgetItem("×" + str(self.bt1)))
                luckinmain.main_ui.tableWidget.setItem(name.index('草莓芝士茶'), 2, QTableWidgetItem(str(self.num_act1)))
            if '草莓芝士茶' not in name:
                if self.bt1 != 0:
                    row_count = luckinmain.main_ui.tableWidget.rowCount()
                    luckinmain.main_ui.tableWidget.insertRow(row_count)
                    luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(activity.activity_ui.label_3.text()))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
                    luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_act1)))
        else:
            if self.bt1 != 0:
                row_count = luckinmain.main_ui.tableWidget.rowCount()
                luckinmain.main_ui.tableWidget.insertRow(row_count)
                luckinmain.main_ui.tableWidget.setItem(row_count, 0, QTableWidgetItem(activity.activity_ui.label_3.text()))
                luckinmain.main_ui.tableWidget.setItem(row_count, 1, QTableWidgetItem("×" + str(self.bt1)))
                luckinmain.main_ui.tableWidget.setItem(row_count, 2, QTableWidgetItem(str(self.num_act1)))

if __name__=="__main__":
    app = QApplication(sys.argv)
    luckinmain = Luckin_Main()
    normal = Normal()
    package = Package()
    activity = Activity()
    # 显示主界面
    luckinmain.person()
    # 绑定按钮
    btn_normal = luckinmain.main_ui.pushButton_2
    btn_normal.clicked.connect(normal.nor_order)
    btn_package = luckinmain.main_ui.pushButton_3
    btn_package.clicked.connect(package.pac_order)
    btn_activity = luckinmain.main_ui.pushButton_4
    btn_activity.clicked.connect(activity.act_order)
    # 初始化name列表
    name = []
    sys.exit(app.exec_())
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479

activity.py

from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QIcon


class Ui_Activity(object):
    def setupUi(self, Form):
        # 设置活动页面ID
        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.setWindowIcon(QIcon('./picture/activity.png'))
        # 设置加入"加入订单"按钮内容
        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", "草莓芝士茶"))
        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", "返回"))

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

luckinmain.py

from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QIcon
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(530, 200, 111, 21))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(530, 230, 72, 15))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(580, 230, 21, 16))
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(530, 260, 81, 21))
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setGeometry(QtCore.QRect(530, 290, 72, 15))
        self.label_5.setObjectName("label_5")
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setGeometry(QtCore.QRect(580, 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, 71, 31))
        self.pushButton_6.setObjectName("pushButton_6")
        self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_7.setGeometry(QtCore.QRect(750, 350, 71, 31))
        self.pushButton_7.setObjectName("pushButton_7")
        self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_8.setGeometry(QtCore.QRect(750, 290, 71, 31))
        self.pushButton_8.setObjectName("pushButton_8")
        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", "luckin coffee"))
        MainWindow.setWindowIcon(QIcon("./Picture/Luckin Coffee.png"))
        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.pushButton_8.setText(_translate("MainWindow", "减少一份"))
        self.label_8.setText(_translate("MainWindow", "图"))

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102

normal.py

from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QIcon,QPixmap

class Ui_Normal(object):
    def setupUi(self, Form):
        # 设置基本餐页面ID
        Form.setObjectName("Form")
        # 设置基本餐页面大小
        Form.resize(728, 459)
        self.pushButton = QtWidgets.QPushButton(Form)
        # setGeometry()
        # 把窗口放到屏幕上并且设置窗口大小。
        # 参数分别代表屏幕坐标的x、y和窗口大小的宽、高。
        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(260, 400, 93, 41))
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_6 = QtWidgets.QPushButton(Form)
        self.pushButton_6.setGeometry(QtCore.QRect(620, 400, 93, 41))
        self.pushButton_6.setObjectName("pushButton_6")
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(62, 170, 72, 15))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(Form)
        self.label_2.setGeometry(QtCore.QRect(65, 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(280, 170, 72, 15))
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(Form)
        self.label_5.setGeometry(QtCore.QRect(295, 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(500, 170, 72, 15))
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(Form)
        self.label_8.setGeometry(QtCore.QRect(514, 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(60, 380, 72, 15))
        self.label_10.setObjectName("label_10")
        self.label_11 = QtWidgets.QLabel(Form)
        self.label_11.setGeometry(QtCore.QRect(63, 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(280, 380, 72, 15))
        self.label_13.setObjectName("label_13")
        self.label_14 = QtWidgets.QLabel(Form)
        self.label_14.setGeometry(QtCore.QRect(280, 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.setWindowIcon(QIcon("./Picture/normal.png"))
        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_3.setScaledContents(True)
        self.label_4.setText(_translate("Form", "钱2"))
        self.label_5.setText(_translate("Form", "拿铁"))
        self.label_6.setText(_translate("Form", "TextLabel"))
        self.label_6.setScaledContents(True)
        self.label_7.setText(_translate("Form", "钱3"))
        self.label_8.setText(_translate("Form", "摩卡"))
        self.label_9.setText(_translate("Form", "TextLabel"))
        self.label_9.setScaledContents(True)
        self.label_10.setText(_translate("Form", "钱4"))
        self.label_11.setText(_translate("Form", "标准美式"))
        self.label_12.setText(_translate("Form", "TextLabel"))
        self.label_12.setScaledContents(True)
        self.label_13.setText(_translate("Form", "钱5"))
        self.label_14.setText(_translate("Form", "焦糖玛奇朵"))
        self.label_15.setText(_translate("Form", "TextLabel"))
        self.label_15.setScaledContents(True)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109

setmeal.py

from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QIcon,QPixmap


class Ui_Setmeal(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(110, 250, 72, 15))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(Form)
        self.label_2.setGeometry(QtCore.QRect(360, 250, 72, 15))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(Form)
        self.label_3.setGeometry(QtCore.QRect(90, 220, 131, 21))
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(Form)
        self.label_4.setGeometry(QtCore.QRect(345, 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, 93, 31))
        self.pushButton_3.setObjectName("pushButton_3")
        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        # 套餐价格
        self.price_set1 = 89.0
        self.price_set2 = 67.0
        Form.setWindowTitle(_translate("Form", "豪华套餐"))
        Form.setWindowIcon(QIcon("./Picture/setmeal.png"))
        self.pushButton.setText(_translate("Form", "加入订单"))
        self.pushButton_2.setText(_translate("Form", "加入订单"))
        self.pushButton_3.setText(_translate("Form", "返回"))
        self.label.setText(_translate("Form", "钱1"))
        self.label.setText(str(self.price_set1) + "元/份")
        self.label_2.setText(_translate("Form", "钱2"))
        self.label_2.setText(str(self.price_set2) + "元/份")
        self.label_3.setText(_translate("Form", "咖啡香茶外送套餐"))
        self.label_4.setText(_translate("Form", "咖啡冰淇淋套餐"))
        self.label_5.setText(_translate("Form", "TextLabel"))
        self.label_5.setPixmap(QPixmap('./picture/套餐2.png'))
        self.label_5.setScaledContents(True)
        self.label_6.setText(_translate("Form", "TextLabel"))
        self.label_6.setPixmap(QPixmap('./picture/套餐1.png'))
        self.label_6.setScaledContents(True)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

我贴的代码是完整的代码,完整复制可以运行只不过不会显示图片。
完整项目可以到我的GitHub中下载(OrderingSystem.zip)。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/80649
推荐阅读
相关标签
  

闽ICP备14008679号