水果2.0来了!!!
这次我们的水果销售2.0, 加入登陆功能,主程序也是增加很多功能。
1、登陆
首先是我们的登陆界面:
from demo import *
import tkinter as tk
win = tk.Tk()
win.title('登陆界面')
win.geometry('400x300+600+250')
# 标签
tk.Label(win, text='登陆', font=('SimHei', 24)).place(x=170, y=20)
tk.Label(win, text='账户:', font=('Arial', 15)).place(x=90, y=90)
tk.Label(win, text='密码:', font=('Arial', 15)).place(x=90, y=140)
# 错误提示标签
mistake = tk.Label(win, fg='red')
mistake.place(x=170, y=167)
# 输入框
# 用户名输入
use_name = tk.Entry(win, font=('Arial', 15), width=12)
use_name.place(x=170, y=90)
# 用户密码输入
use_password = tk.Entry(win, font=('Arial', 15), width=12, show='*')
use_password.place(x=170, y=140)
def us_na():
global use_name
use = use_name
return use
def Mian():
use_name__ = use_name.get()
use_password__ = use_password.get()
sql = "select * from user where name = %s and password = %s"
rows = cursor.execute(sql, (use_name__, use_password__))
if rows != 0:
# io流写入用户名
f = open(r'E:\pywork\demo\use_name_io\name_io.txt', 'w')
f.write(use_name.get())
f.flush()
f.close()
win.destroy()
import demo.main_system
else:
mistake.configure(text='账户或者密码错误')
# 登陆界面的按钮
butt_login = tk.Button(win, text='登陆', width=10, command=Mian)
butt_login.place(x=40, y=207)
butt_register = tk.Button(win, text='注册', width=10, command=Register)
butt_register.place(x=150, y=207)
butt_Reset = tk.Button(win, text='忘记密码', width=10, command=Updata)
butt_Reset.place(x=260, y=207)
win.mainloop()
2、注册功能
import tkinter as tk
from demo.market_mysql import *
# 注册页面
def Register():
global use_name_register
win_ = tk.Tk()
win_.title('注册')
win_.geometry('380x400+200+200')
# 注册的标签
tk.Label(win_, text='注册', font=('SimHei', 24)).place(x=170, y=20)
tk.Label(win_, text='账户', font=('KaiTi', 15)).place(x=50, y=70)
tk.Label(win_, text='密码', font=('KaiTi', 15)).place(x=50, y=120)
tk.Label(win_, text='确认密码', font=('KaiTi', 15)).place(x=50, y=170)
# 密码不一致错误提示
mistake_register = tk.Label(win_, fg='red')
mistake_register.place(x=170, y=200)
# 密保
encrypted = tk.Label(win_, text='密保', font=('KaiTi', 13))
encrypted.place(x=50, y=250)
# 用户名输入
use_name_register = tk.Entry(win_, font=('FangSong', 15), width=12)
use_name_register.place(x=170, y=67)
# 用户密码输入
use_password_register = tk.Entry(win_, font=('FangSong', 15), width=12, show='*')
use_password_register.place(x=170, y=117)
# 重复密码输入
use_password_register2 = tk.Entry(win_, font=('FangSong', 15), width=12, show='*')
use_password_register2.place(x=170, y=167)
# 密保出入框
use_password_encrypted = tk.Entry(win_, font=('FangSong', 15), width=12)
use_password_encrypted.place(x=170, y=245)
def ietm():
global useName
def Sure():
use_Pass1 = use_password_register.get()
use_Pass2 = use_password_register2.get()
# 验证俩次输入的密码是否相同
if use_Pass1 != use_Pass2:
mistake_register.configure(text='两次密码不一致,请重试')
elif use_Pass1 == use_Pass2:
# 获取输入的值
user_name = use_name_register.get()
print("here ", user_name)
user_password = use_password_register.get()
user_encrypted = use_password_encrypted.get()
# 插入mysql的语句
sql = "insert into user(name, password, encrypted) values (%s, %s, %s)"
cursor.execute(sql, (user_name, user_password, user_encrypted))
conn.commit()
win_.destroy()
# 注册界面的确定和取消
butt_Reg_sure = tk.Button(win_, text='确认', font=('KaiTi', 15), width=8, command=Sure)
butt_Reg_sure.place(x=50, y=320)
butt_Reg_cancel = tk.Button(win_, text='取消', font=('KaiTi', 15), width=8)
butt_Reg_cancel.place(x=230, y=320)
win_.mainloop()
3、重置密码
import tkinter as tk
from demo.market_mysql import *
import demo.register
def Updata():
up = tk.Tk()
up.title('忘记密码')
up.geometry('300x250+1050+300')
# 输入标签
tk.Label(up, text='重置密码', font=('SimHei', 20)).pack()
tk.Label(up, text='用户名', font=("KaiTi", 13)).place(x=30, y=70)
tk.Label(up, text='密保', font=('KaiTi', 13)).place(x=30, y=120)
tk.Label(up, text='新的密码', font=('KaiTi', 13)).place(x=30, y=170)
# 错误提示标签con
mistakes_updata = tk.Label(up, fg='red')
mistakes_updata.place(x=150, y=185)
# 输入框
# 用户名输入框
user_name_ = tk.Entry(up, font=('FangSong', 15), width=10)
user_name_.place(x=150, y=67)
# 密保输入框
user_encrypted_ = tk.Entry(up, font=('FangSong', 15), width=10)
user_encrypted_.place(x=150, y=117)
# 新密码输入框
user_new_password = tk.Entry(up, font=('FangSong', 15), width=10)
user_new_password.place(x=150, y=160)
def Reset():
reset_encrypted = user_encrypted_.get()
rest_user_name = user_name_.get()
New_password = user_new_password.get()
sql = "select encrypted from user where name='%s' and encrypted ='%s'" % (rest_user_name, reset_encrypted)
rows = cursor.execute(sql)
conn.commit()
if rows > 0:
sql = "update user set password = %s where name = %s"
cursor.execute(sql, (New_password, rest_user_name))
conn.commit()
up.destroy()
else:
mistakes_updata.configure(text='密保有误')
# 忘记密码的确定按钮
butt_sure = tk.Button(up, text='确定', width=10, font=('FangSong', 13), command=Reset)
butt_sure.place(x=100, y=210)
up.mainloop()
4、数据库连接
import pymysql
conn = pymysql.connect(host='127.0.0.1',
port=3306,
user='数据库用户名',
password='数据库密码',
database='数据库库名',
charset='utf8')
cursor = conn.cursor()
5、主程序
import tkinter as tk
from tkinter import ttk
import io
chucun_chongzhi = 0
win_zhu = tk.Tk()
win_zhu.title("商品显示页面")
win_zhu.geometry("700x700+400+20")
# 标题容器
title_frame = tk.Frame(win_zhu, width=690, borderwidth=1, height=50)
title_frame.place(x=5, y=5)
# 切换页面的按钮容器
qie_but_frame = tk.Frame(win_zhu, width=460, borderwidth=1, height=80)
qie_but_frame.place(x=5, y=55)
# 添加到购物车页面容器
gou_frame = tk.Frame(win_zhu, width=225, borderwidth=1, height=640)
gou_frame.place(x=465, y=55)
# 字典存储信息
cunchu_xuhao = {}
cunchu_gouwuche = {}
cunchu_gouwuzongjia = {}
# 初始化图片
def img_pho(imgg):
phoh = tk.PhotoImage(file=imgg)
return phoh
pho1 = img_pho("photo\香蕉.gif")
pho2 = img_pho("photo\苹果.gif")
pho3 = img_pho("photo\梨子.gif")
pho4 = img_pho("photo\樱桃.gif")
pho5 = img_pho("photo\西瓜.gif")
pho6 = img_pho("photo\葡萄.gif")
pho7 = img_pho("photo\桃子.gif")
pho8 = img_pho("photo\橘子.gif")
pho9 = img_pho("photo\荔枝.gif")
# 定义商品展示的函数
def show_commodity(img, frame_C, xx, yy, name, jiage, xuhao):
# 缓冲字典
zancunchu_name_jiage = {}
# 去除¥
zancunchu_name_jiage[name] = jiage.strip('¥')
# 把信息添加到存储器
cunchu_xuhao[xuhao] = zancunchu_name_jiage
fr = tk.Frame(frame_C, width=120, borderwidth=1, height=150, bg="#F2F5A9")
fr.place(x=xx, y=yy)
img_lab = tk.Label(fr, image=img, width=112, height=90)
img_lab.place(x=1, y=1)
name_lab = tk.Label(fr, text=name, font=("Arial", 17), bg="#F2F5A9")
name_lab.place(x=7, y=95)
jiage_lab = tk.Label(fr, text=jiage, font=("Arial", 14), bg="#F2F5A9")
jiage_lab.place(x=65, y=95)
xuhao_lab = tk.Label(fr, text=xuhao, font=("Arial", 12), bg="#F2F5A9")
xuhao_lab.place(x=50, y=120)
# 设置商品页面
def put_wuping():
# 商品展示页面容器
show_frame_s = tk.Frame(win_zhu, width=460, borderwidth=1, height=560)
show_frame_s.place(x=5, y=135)
global pho1
show_commodity(pho1, show_frame_s, 20, 20, "香蕉", "¥10", "001")
global pho2
show_commodity(pho2, show_frame_s, 165, 20, "苹果", "¥20", "002")
global pho3
show_commodity(pho3, show_frame_s, 312, 20, "梨子", "¥30", "003")
global pho4
show_commodity(pho4, show_frame_s, 20, 200, "樱桃", "¥40", "004")
global pho5
show_commodity(pho5, show_frame_s, 165, 200, "西瓜", "¥50", "005")
global pho6
show_commodity(pho6, show_frame_s, 312, 200, "葡萄", "¥60", "006")
global pho7
show_commodity(pho7, show_frame_s, 20, 390, "桃子", "¥70", "007")
global pho8
show_commodity(pho8, show_frame_s, 165, 390, "橘子", "¥80", "008")
global pho9
show_commodity(pho9, show_frame_s, 312, 390, "荔枝", "¥90", "009")
return show_frame_s
# 这是实现购物车功能的函数
def gouwuche():
# 购物车展示页面容器
show_frame_g = tk.Frame(win_zhu, width=460, borderwidth=1, height=560)
show_frame_g.place(x=5, y=135)
columns = ("xuhao", "name", "quantity", "balance")
treeview = ttk.Treeview(show_frame_g, height=17, show="headings", columns=columns)
treeview.place(x=5, y=5)
treeview.heading("xuhao", text="序号")
treeview.heading("name", text="名称")
treeview.heading("quantity", text="数量")
treeview.heading("balance", text="价格")
treeview.column("xuhao", width=110, anchor="center")
treeview.column("name", width=110, anchor="center")
treeview.column("quantity", width=110, anchor="center")
treeview.column("balance", width=115, anchor="center")
m = 0
for i, j in cunchu_gouwuche.items():
for name, quantity in j.items():
treeview.insert("", m, values=(
i, name, quantity, int(quantity) * int(str(*[k for k in (cunchu_xuhao.get(i)).values()]))))
m += 1
# 充值金额显示名和显示框
chongzhi_name = tk.Label(show_frame_g, text="充值金额:", font=("Arial", 17))
chongzhi_name.place(x=50, y=375)
chongzhi_show = tk.Label(show_frame_g, text=chucun_chongzhi, font=("Arial", 17))
chongzhi_show.place(x=155, y=375)
# 设置总价名和显示框
zongjia_name = tk.Label(show_frame_g, text="总价:", font=("Arial", 17))
zongjia_name.place(x=50, y=420)
zongjia_show = tk.Label(show_frame_g, text="", font=("Arial", 17))
zongjia_show.place(x=155, y=420)
# 设置余额名和显示框
yu_e_name = tk.Label(show_frame_g, text="余额:", font=("Arial", 17))
yu_e_name.place(x=50, y=465)
yu_e_show = tk.Label(show_frame_g, text="", font=("Arial", 17))
yu_e_show.place(x=155, y=465)
# 这里是实现单个商品结算功能的函数
# 结算按钮的回调函数(余额不足则退出程序的功能和重新充值)
def jiesuan_bt():
# 计算所有商品总价
result = 0
for i, j in cunchu_gouwuzongjia.items():
result = result + int(j)
zongjia_show.configure(text=str(result))
# 计算最后的余额
yu_e_show.configure(text=str(chucun_chongzhi - result))
# 结算时余额为负数显示函数
def fu_e_jiesuan():
win_jiesuan = tk.Tk()
win_jiesuan.title("结算界面")
win_jiesuan.geometry("300x300")
# 定义结算界面的标题
jiesuan_title = tk.Label(win_jiesuan, text="结算系统", font=("Arial", 17))
jiesuan_title.place(x=100, y=10)
# 设置充值金额显示名和框
cz_name = tk.Label(win_jiesuan, text="充值金额:", font=("Arial", 14))
cz_name.place(x=50, y=50)
cz_box = tk.Label(win_jiesuan, text=chucun_chongzhi, font=("Arial", 14), bg="pink", width=8)
cz_box.place(x=150, y=50)
# 设置总价的显示名和框
zj_name = tk.Label(win_jiesuan, text="商品总价:", font=("Arial", 14))
zj_name.place(x=50, y=90)
zj_box = tk.Label(win_jiesuan, text=result, font=("Arial", 14), bg="pink", width=8)
zj_box.place(x=150, y=90)
# 设置余额的显示名和框
y_e_name = tk.Label(win_jiesuan, text="剩余额度:", font=("Arial", 14))
y_e_name.place(x=50, y=130)
y_e_box = tk.Label(win_jiesuan, text=chucun_chongzhi - result, font=("Arial", 14), bg="pink", width=8)
y_e_box.place(x=150, y=130)
# 设置提示框
ts_box = tk.Label(win_jiesuan, text="穷逼,回去做梦吧!", font=("Arial", 19), bg="#DAB4F3", width=14, height=2)
ts_box.place(x=40, y=170)
# 设置退出程序按钮的回调函数
def tuichu_bt():
win_zhu.destroy()
win_jiesuan.destroy()
# 设置返回充值按钮的回调函数
def f_h_zhongzhi():
win_jiesuan.destroy()
input_money()
# 设置退出程序按钮和重新充值按钮
exit_but = tk.Button(win_jiesuan, text="退出程序", font=("Arial", 14), width=8, height=1, command=tuichu_bt)
exit_but.place(x=10, y=245)
new_cz_but = tk.Button(win_jiesuan, text="重新充值", font=("Arial", 14), width=8, height=1,
command=f_h_zhongzhi)
new_cz_but.place(x=190, y=245)
win_jiesuan.mainloop()
if chucun_chongzhi - result > 0:
pass
else:
fu_e_jiesuan()
# 结算所有商品功能函数
# 定义结算按钮(余额不足则退出程序的功能和重新充值)
jiesuan_but = tk.Button(show_frame_g, text="结算", width=7, height=1, font=("Arial", 14), command=jiesuan_bt)
jiesuan_but.place(x=50, y=510)
# 清除按钮的回调函数
def qingchu_bt():
# 判断为空时
if cunchu_gouwuche == {}:
# 刷新提示
show_del_result.configure(text=str("购物车无商品"))
for i in cunchu_gouwuche.keys():
if i == entry_box.get():
# 刷新提示
show_del_result.configure(text=str("正在进行删除"))
win_qingchu = tk.Tk()
win_qingchu.title("清除界面")
win_qingchu.geometry("300x300+600+250")
# 删除界面标题
title_qingchu = tk.Label(win_qingchu, text="删除系统", font=("Arial", 17))
title_qingchu.place(x=100, y=10)
# 定义商品序号名和框
del_xuhao_name = tk.Label(win_qingchu, text="商品序号:", font=("Arial", 14))
del_xuhao_name.place(x=60, y=50)
del_xuhao_show = tk.Label(win_qingchu, text=entry_box.get(), font=("Arial", 14), bg="pink", width=7)
del_xuhao_show.place(x=170, y=50)
# 定义商品名称和框
commodity_name_show = tk.Label(win_qingchu, text="商品名称:", font=("Arial", 14))
commodity_name_show.place(x=60, y=90)
commodity_box_show = tk.Label(win_qingchu,
text=str(*[k for k in (cunchu_gouwuche.get(entry_box.get())).keys()]),
font=("Arial", 14), bg="pink", width=7)
commodity_box_show.place(x=170, y=90)
# 删除提示信息显示框
tishi_show_box = tk.Label(win_qingchu, text="请您三思而后行!", font=("Arial", 19), bg="#DAB4F3", width=17,
height=3)
tishi_show_box.place(x=20, y=130)
# 设置不思考和思考一下按钮的回调函数
def no_sikao():
# 删除购物车中的元素
cunchu_gouwuche.pop(entry_box.get())
# 删除元素的总价
cunchu_gouwuzongjia.pop(entry_box.get())
# 刷新提示
show_del_result.configure(text=str("以完成删除"))
# 销毁页面
win_qingchu.destroy()
# 刷新购物车
gouwuche()
def yes_sikao():
show_del_result.configure(text=str("输入商品序号"))
win_qingchu.destroy()
# 设置删除和不删除按钮
yes_del_but = tk.Button(win_qingchu, text="不用思考", width=8, font=("Arial", 11), height=2,
command=no_sikao)
yes_del_but.place(x=20, y=230)
no_del_but = tk.Button(win_qingchu, text="思考一下", width=8, font=("Arial", 11), height=2,
command=yes_sikao)
no_del_but.place(x=200, y=230)
win_qingchu.mainloop()
else:
show_del_result.configure(text=str("无此序号!"))
# 设置清除功能(清除购物车商品的功能)
qingchu_name = tk.Label(show_frame_g, text="输入商品序号", font=("Arial", 17))
qingchu_name.place(x=280, y=375)
entry_box = tk.Entry(show_frame_g, width=15, font=("Arial", 14))
entry_box.place(x=270, y=410)
show_del_result = tk.Label(show_frame_g, text="输入序号删除", font=("Arial", 15), bg="pink", width=12, height=2)
show_del_result.place(x=280, y=447)
jiesuan_but = tk.Button(show_frame_g, text="清除该商品", width=10, height=1, font=("Arial", 14), command=qingchu_bt)
jiesuan_but.place(x=290, y=510)
return show_frame_g
# 读取用户
f = open(r'E:\pywork\demo\use_name_io\name_io.txt', 'r')
name_user = f.read()
# 定义小程序的标题
title_small_name1 = tk.Label(title_frame, bg='#F5A9F2', text="用户:" + str(name_user), font=("Arial", 11))
title_small_name1.place(x=15, y=13)
f.flush()
f.close()
title_big_name = tk.Label(title_frame, text="超市水果销售系统", font=("Arial", 23))
title_big_name.place(x=195, y=3)
# 实现充值的函数
def input_money():
win_money = tk.Tk()
win_money.title("充值")
win_money.geometry("400x320+600+250")
# 输入框名
input_money_name = tk.Label(win_money, text="请输入金额", font=("Arial", 20))
input_money_name.place(x=130, y=30)
# 输入框
entry_box = tk.Entry(win_money, width=20, font=("Arial", 20))
entry_box.place(x=50, y=80)
use_name_money = tk.Entry(win_money, )
# 格式提示
show_name = tk.Label(win_money, text="输入您要充值的金额", font=("Arial", 18), bg="#D8A6F0", width=18, height=2)
show_name.place(x=60, y=140)
# 确定按钮的回调函数
def yes_bt():
global chucun_chongzhi
money = str(entry_box.get())
if money.isdigit():
show_name.configure(text=str("输入正确,充值成功"))
chucun_chongzhi = int(money)
win_money.destroy()
gouwuche()
else:
show_name.configure(text=str("格式错误,请重新输入"))
# 取消按钮的回调函数
def del_bt():
entry_box.delete(0, len(entry_box.get()))
# 确认按钮
yes_but = tk.Button(win_money, text="确定", command=yes_bt, width=10, height=2)
yes_but.place(x=50, y=230)
# 清空按钮
no_but = tk.Button(win_money, text="清空", command=del_bt, width=10, height=2)
no_but.place(x=250, y=230)
win_money.mainloop()
# 充值窗口按钮
input_money_butt = tk.Button(title_frame, text='充值', width=10, command=input_money)
input_money_butt.place(x=585, y=13)
# 用于切换页面
# 定义商品按钮和购物车按钮的调用与销毁
def show_s_but_name():
gouwuche().destroy()
put_wuping()
def show_g_but_name():
put_wuping().destroy()
gouwuche()
# 定义显示商品按钮
show_s_but = tk.Button(qie_but_frame, text="商店", width=15, height=2, font=("Arial", 12), command=show_s_but_name)
show_s_but.place(x=50, y=13)
# 定义显示购物车按钮
show_g_but = tk.Button(qie_but_frame, text="购物车", width=15, height=2, font=("Arial", 12), command=show_g_but_name)
show_g_but.place(x=255, y=13)
# 定义序号显示名和输入框(添加购物车功能)
xuhao_show_name = tk.Label(gou_frame, text="商品序号", font=("Arial", 21))
xuhao_show_name.place(x=55, y=10)
xuhao_entry = tk.Entry(gou_frame, font=("Arial", 20), width=12)
xuhao_entry.place(x=18, y=70)
# 定义数量显示名和输入框(添加购物车功能)
quantity_show_name = tk.Label(gou_frame, text="购买数量", font=("Arial", 21))
quantity_show_name.place(x=55, y=155)
quantity_entry = tk.Entry(gou_frame, font=("Arial", 20), width=12)
quantity_entry.place(x=18, y=215)
# 定义提示语框
tishiyu_lab = tk.Label(gou_frame, text="请输入商品的\n序号和数量\n添加至购物车", font=("Arial", 17), bg="#D4F1EE", width=12, height=5)
tishiyu_lab.place(x=27, y=310)
# 把商品添加到购物车的函数
def gouwuche_bt():
# 获取序号
get_xuhao = xuhao_entry.get()
# 获取购买数量
get_quatity = quantity_entry.get()
# 获取序号对应的字典
xh_dict = cunchu_xuhao.get(get_xuhao)
def tj_gouwuche_yemian():
tishiyu_lab.configure(text=str("正在进行\n商品添加操作"))
win_gouwuche = tk.Tk()
win_gouwuche.title("添加商品页面")
win_gouwuche.geometry("300x330")
# 设置添加商品页面的标题
title_gouwuche = tk.Label(win_gouwuche, text="添加商品", font=("Arial", 17))
title_gouwuche.place(x=100, y=10)
# 商品序号和显示框
sp_xuhao_name = tk.Label(win_gouwuche, text="商品序号:", font=("Arial", 14))
sp_xuhao_name.place(x=50, y=50)
sp_xuhao_show = tk.Label(win_gouwuche, text=get_xuhao, font=("Arial", 14), bg="pink", width=8)
sp_xuhao_show.place(x=150, y=50)
# 商品名称和显示框
sp_name_name = tk.Label(win_gouwuche, text="商品名称:", font=("Arial", 14))
sp_name_name.place(x=50, y=90)
sp_name_show = tk.Label(win_gouwuche, text=str(*[i for i in xh_dict.keys()]), font=("Arial", 14), bg="pink",
width=8)
sp_name_show.place(x=150, y=90)
# 商品数量和显示框
sp_quantity_name = tk.Label(win_gouwuche, text="商品数量:", font=("Arial", 14))
sp_quantity_name.place(x=50, y=130)
sp_quantity_show = tk.Label(win_gouwuche, text=get_quatity, font=("Arial", 14), bg="pink", width=8)
sp_quantity_show.place(x=150, y=130)
# 商品单价和显示框
sp_danjia_name = tk.Label(win_gouwuche, text="商品单价:", font=("Arial", 14))
sp_danjia_name.place(x=50, y=170)
sp_danjia_show = tk.Label(win_gouwuche, text=str(*[i for i in xh_dict.values()]), font=("Arial", 14), bg="pink",
width=8)
sp_danjia_show.place(x=150, y=170)
# 商品总价和显示框
sp_zongjia_name = tk.Label(win_gouwuche, text="商品总价:", font=("Arial", 14))
sp_zongjia_name.place(x=50, y=210)
sp_zongjia_show = tk.Label(win_gouwuche, text=int(get_quatity) * int(str(*[i for i in xh_dict.values()])),
font=("Arial", 14), bg="pink", width=8)
sp_zongjia_show.place(x=150, y=210)
# 确定按钮的回调函数
def sp_yes_bt():
buffer = {}
buffer[str(*[i for i in xh_dict.keys()])] = get_quatity
cunchu_gouwuche[get_xuhao] = buffer
cunchu_gouwuzongjia[get_xuhao] = str(int(get_quatity) * int(str(*[i for i in xh_dict.values()])))
tishiyu_lab.configure(text=str("请输入商品的\n序号和数量\n添加至购物车"))
gouwuche()
win_gouwuche.destroy()
# 设置确定添加按钮
sp_yes_but = tk.Button(win_gouwuche, text="确定添加", font=("Arial", 14), width=8, command=sp_yes_bt)
sp_yes_but.place(x=20, y=260)
# 取消按钮的回调函数
def sp_no_bt():
tishiyu_lab.configure(text=str("请输入商品的\n序号和数量\n添加至购物车"))
win_gouwuche.destroy()
# 设置取消添加按钮
sp_no_but = tk.Button(win_gouwuche, text="取消添加", font=("Arial", 14), width=8, command=sp_no_bt)
sp_no_but.place(x=180, y=260)
win_gouwuche.mainloop()
for i in cunchu_xuhao.keys():
if get_xuhao == i:
tj_gouwuche_yemian()
else:
tishiyu_lab.configure(text=str("无此商品的\n序号,请重新\n输入,thanks"))
# 设置添加到购物车按钮
add_gouwuche_but = tk.Button(gou_frame, text="添加至购物车", font=("Arial", 15), width=17, height=3, command=gouwuche_bt)
add_gouwuche_but.place(x=15, y=500)
win_zhu.mainloop()
程序代码到此结束了,下面是运行截图:
6、运行结果
登陆界面:
注册界面:
重置密码页面:
主程序: