一、系统概述
餐厅服务管理系统是一个信息管理系统,不仅能管理大量数据,也能给用户提供方便快捷的服务。餐厅服务管理系统主要以餐厅中的会员、菜单、订单为蓝本,对这些信息进行查找、添加、删除等处理,方便管理员更好的管理餐厅,提高工作效率。同时顾客也可以从中获得多样化的优质服务,提高顾客的用餐体验以,满足现代餐饮业的发展需求。
二、功能需求描述
餐厅管理系统的主要包括了管理员和用户两个角色。
管理员进入系统可以实现订单查看、会员查看、菜单管理等;
用户的主要功能包括会员的查询、注册、修改、注销服务和点餐服务等。
三、系统设计
1.功能模块
依据需求分析结果,餐厅服务管理系统由三大功能模块组成,详见下图:
2.数据结构设计
class Vip():
class Rest():
class Ordor():
该系统中定义了3个类,分别对应着会员服务、后台管理、点餐服务的3大功能,3者对应的信息存储在相应的文件内。
3.信息储存
(1)有关会员的信息以字典的形式储存在vips.txt文档中(需自行注册)
(2)有关菜单的信息以字典的方式储存在menus.txt文档中(需要自行添加)
(3)与订单有关的信息以列表的形式储存在orders.txt文档中(需要自行生成订单)
4.程序命令设计
5.界面设计
Tkinter是Python标准库中的一个模块,用于创建GUI应用程序。
基本步骤通常包括:
- 导入 tkinter 模块
- 创建 GUI 根窗体
- 添加人机交互控件并编写相应的函数。
- 在主事件循环中等待用户触发事件响应
本系统中用到的 tkinter 控件
控件
名称
作用
Button
按钮
单击触发事件
Entry
输入框
接收单行文本输入
Label
标签
单行文本显示
Text
文本框
接收或输出显示多行文本
四、系统实现
由于各部分的代码实现都较为分散,因此故不一一展示出来,文章最后会给出完整代码。
1、查看会员:从文本框中读取要查询的账号,并在vips.txt文件中寻找账号,如果找到对应账号,则为会员,否则不是。
2、注册会员:从文本框中读取注册会员时的账号与密码,并储存到文件vips.txt中
3、注销会员:从文本框中读取要注销会员的账号与密码,并在vips.txt文件中寻找账号,如果找到对应账号,则会将该账号在文件中删除,找不到则提示密码错误或该账号不是会员。
4、修改会员:由于会员中存储的信息较少,故采用将该账号注销后重新注册的方法实现会员的修改功能。
5、餐厅登录:为了保护用户及餐厅的相关信息,故将会员查看、菜单管理和订单查看的功能需要登录上餐厅的密码才能使用相关功能。(账号:20232024 密码:123456)
6、会员查看:将vips.txt文件中的所有账号和密码按照一定的排版展示出来。
7、订单查看:将orders.txt文件中的所有存储的信息按照一定的排版展示出来。
8、菜单的添加、删除:有关菜单的添加与删除,其原理与会员的添加与删除类似,其储存信息的文件为menus.txt。
9、菜单查看:将menus.txt文件中的所有账号和密码按照一定的排版展示出来。
10、点餐服务
1)区分是否为会员,是会员登录账号密码,不是会员输入手机号。
2)进入点餐界面
3)添加所选菜品到右下方文本框
4)如选错商品可以点击清空重新选择,点击清空后右下方文本框会被清空
5)点击确认点餐,则会自动生成订单,并将该订单储存到orders.txt文件中。是会员的话能在本店享受9折优惠,不是会员的则没有此优惠。因此2者生成的订单在折扣和实付方面有区别。
五、代码程序
from tkinter import *
from tkinter import messagebox as msgbox
def fanhui(root_d, root_t):
root_d.attributes('-alpha', 1)
root_t.destroy()
def zhuxiao(root_t):
root_t.destroy()
def get_info(a):
with open(a, 'r', encoding='utf-8') as rfile:
info_lst = rfile.readlines()
info_dir = []
for i in info_lst:
info_dir.append(eval(i))
return info_dir
def run1(root_t):
root_t.attributes('-alpha', -1)
tk = Vip()
tk.windows()
def run2(a, b, root_t):
user = a.get()
passwd = b.get()
if user == "20232024" and passwd == "123456":
root_t.destroy()
rest = Rest()
rest.windows()
else:
msgbox.showinfo('失败!', '请重新输入')
def dl_rest_jm(root_t):
root_t.attributes('-alpha', -1)
win = Tk()
win.geometry("600x400")
win.title("登录餐厅")
rest_user = Entry(win, font=('宋体', 15))
rest_user.place(relx=0.3, rely=0.32, relwidth=0.5, relheight=0.1)
rest_pass = Entry(win, show="*", font=('宋体', 15))
rest_pass.place(relx=0.3, rely=0.52, relwidth=0.5, relheight=0.1)
name = Label(win, text="请输入餐厅账号:", font=('宋体', 15))
name.place(relx=0.15, rely=0.15, relwidth=0.28, relheight=0.15)
name1 = Label(win, text="用户名:", font=('宋体', 15), width=10)
name1.place(relx=0.15, rely=0.3, relwidth=0.15, relheight=0.15)
name2 = Label(win, text="密码:", font=('宋体', 15), width=10)
name2.place(relx=0.15, rely=0.5, relwidth=0.15, relheight=0.15)
button = Button(win, text="登录", font=('宋体', 15), command=lambda: run2(rest_user, rest_pass, win))
button.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
btn1_6 = Button(win, text='返回', command=lambda: fanhui(root, win))
btn1_6.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
win.mainloop()
def run3(root_t):
root_t.attributes('-alpha', -1)
tk = Ordor()
tk.windows()
class Vip():
def __init__(self):
self.root_1 = Tk()
def cx_gn(self):
username = self.username1.get()
self.username1.delete(0, END)
for i in get_info('vips.txt'):
if username == (i['账号']):
msgbox.showinfo('成功', '你是本店会员!')
break
else:
msgbox.showerror('失败!', '没有找到该账号!')
fanhui(self.root_1, self.root1)
def cx_jm(self):
self.root_1.attributes('-alpha', -1)
self.root1 = Tk()
self.root1.geometry("600x400")
self.root1.title("查询")
self.username1 = Entry(self.root1, font=('宋体', 15))
self.username1.place(relx=0.2, rely=0.4, relwidth=0.6, relheight=0.15)
name = Label(self.root1, text="请输入账号:", font=('宋体', 20))
name.place(relx=0.15, rely=0.2, relwidth=0.4, relheight=0.15)
button_1 = Button(self.root1, text='返回', command=lambda: fanhui(self.root_1, self.root1))
button_1.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
button_2 = Button(self.root1, text="查询", font=('宋体', 15), width=10, command=self.cx_gn)
button_2.place(relx=0.35, rely=0.65, relwidth=0.3, relheight=0.15)
self.root1.mainloop()
def zc_gn(self):
vip = []
username = self.username2.get()
passwd1 = self.passwd1.get()
passwd2 = self.passwd2.get()
self.username2.delete(0, END)
self.passwd1.delete(0, END)
self.passwd2.delete(0, END)
if passwd1 == '' or passwd2 == '':
return msgbox.showerror('失败!', '不能填空!!!')
if passwd1 != passwd2:
msgbox.showerror('失败!', '注册失败,两次密码不一致!')
else:
msgbox.showinfo('成功', '恭喜你注册成功!')
vip.append({'账号': username, '密码': passwd2, })
with open('vips.txt', 'a', encoding='utf-8') as file:
for i in vip:
file.write(str(i) + '\n')
fanhui(self.root_1, self.root2)
def zc_jm(self):
self.root_1.attributes('-alpha', -1)
self.root2 = Tk()
self.root2.geometry("600x400")
self.root2.title("注册")
self.username2 = Entry(self.root2, font=('宋体', 15))
self.passwd1 = Entry(self.root2, show="*", font=('宋体', 15))
self.passwd2 = Entry(self.root2, show="*", font=('宋体', 15))
self.username2.place(relx=0.35, rely=0.18, relwidth=0.5, relheight=0.1)
self.passwd1.place(relx=0.35, rely=0.38, relwidth=0.5, relheight=0.1)
self.passwd2.place(relx=0.35, rely=0.58, relwidth=0.5, relheight=0.1)
name1 = Label(self.root2, text="用户名:", font=('宋体', 15), width=10)
name1.place(relx=0.15, rely=0.15, relwidth=0.18, relheight=0.15)
name2 = Label(self.root2, text="密码:", font=('宋体', 15), width=10)
name2.place(relx=0.15, rely=0.35, relwidth=0.18, relheight=0.15)
name3 = Label(self.root2, text="确认密码:", font=('宋体', 15), width=10)
name3.place(relx=0.15, rely=0.55, relwidth=0.18, relheight=0.15)
button_1 = Button(self.root2, text="返回", font=('宋体', 10), width=5,
command=lambda: fanhui(self.root_1, self.root2))
button_1.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
button_2 = Button(self.root2, text="注册", font=('宋体', 15), width=10, command=self.zc_gn)
button_2.place(relx=0.35, rely=0.75, relwidth=0.3, relheight=0.15)
self.root2.mainloop()
def xg_jm(self):
self.root_1.attributes('-alpha', -1)
self.root3 = Tk()
self.root3.geometry("600x400")
self.root3.title("修改")
username3 = Entry(self.root3, font=('宋体', 15))
username3.place(relx=0.3, rely=0.32, relwidth=0.5, relheight=0.1)
passwd3 = Entry(self.root3, show="*", font=('宋体', 15))
passwd3.place(relx=0.3, rely=0.52, relwidth=0.5, relheight=0.1)
name1 = Label(self.root3, text="请输入要修改的账号:", font=('宋体', 15))
name1.place(relx=0.15, rely=0.15, relwidth=0.35, relheight=0.15)
name2 = Label(self.root3, text="用户名:", font=('宋体', 15), width=10)
name2.place(relx=0.15, rely=0.3, relwidth=0.15, relheight=0.15)
name3 = Label(self.root3, text="密码:", font=('宋体', 15), width=10)
name3.place(relx=0.15, rely=0.5, relwidth=0.15, relheight=0.15)
button_1 = Button(self.root3, text="注销后重新注册", font=('宋体', 15),
command=lambda: self.zx_gn(username3, passwd3))
button_1.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
button_2 = Button(self.root3, text='返回', command=lambda: fanhui(self.root_1, self.root3))
button_2.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root3.mainloop()
def zx_gn(self, a, b):
zx_vip = get_info('vips.txt')
user = a.get()
passwd = b.get()
a.delete(0, END)
b.delete(0, END)
for i in zx_vip:
if user == (i['账号']) and passwd == (i['密码']):
zx_vip.remove(i)
with open('vips.txt', 'w', encoding='utf-8') as file:
for j in zx_vip:
file.write(str(j) + '\n')
msgbox.showinfo('成功', '注销成功!')
break
else:
msgbox.showinfo('失败!', '密码错误或该账号不是会员')
def zx_jm(self):
self.root_1.attributes('-alpha', -1)
self.root4 = Tk()
self.root4.geometry("600x400")
self.root4.title("注销")
username4 = Entry(self.root4, font=('宋体', 15))
username4.place(relx=0.3, rely=0.32, relwidth=0.5, relheight=0.1)
passwd4 = Entry(self.root4, show="*", font=('宋体', 15))
passwd4.place(relx=0.3, rely=0.52, relwidth=0.5, relheight=0.1)
name1 = Label(self.root4, text="请输入要注销的账号:", font=('宋体', 15))
name1.place(relx=0.15, rely=0.15, relwidth=0.35, relheight=0.15)
name2 = Label(self.root4, text="用户名:", font=('宋体', 15), width=10)
name2.place(relx=0.15, rely=0.3, relwidth=0.15, relheight=0.15)
name3 = Label(self.root4, text="密码:", font=('宋体', 15), width=10)
name3.place(relx=0.15, rely=0.5, relwidth=0.15, relheight=0.15)
button_1 = Button(self.root4, text="注销", font=('宋体', 15), command=lambda: self.zx_gn(username4, passwd4))
button_1.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
button_2 = Button(self.root4, text='返回', command=lambda: fanhui(self.root_1, self.root4))
button_2.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root4.mainloop()
def windows(self):
self.root_1.geometry("600x400")
self.root_1.title("会员管理")
lb1_1 = Label(self.root_1, text='请点击功能', font=('宋体', 15))
lb1_1.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.2)
btn1_1 = Button(self.root_1, text='查询', font=('宋体', 15), command=self.cx_jm)
btn1_1.place(relx=0.17, rely=0.35, relwidth=0.3, relheight=0.15)
btn1_2 = Button(self.root_1, text='注册', font=('宋体', 15), command=self.zc_jm)
btn1_2.place(relx=0.54, rely=0.35, relwidth=0.3, relheight=0.15)
btn1_3 = Button(self.root_1, text='修改', font=('宋体', 15), command=self.xg_jm)
btn1_3.place(relx=0.17, rely=0.6, relwidth=0.3, relheight=0.15)
btn1_4 = Button(self.root_1, text='注销', font=('宋体', 15), command=self.zx_jm)
btn1_4.place(relx=0.54, rely=0.6, relwidth=0.3, relheight=0.15)
btn1_6 = Button(self.root_1, text='返回', command=lambda: fanhui(root, self.root_1))
btn1_6.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root_1.mainloop()
class Rest():
def __init__(self):
self.root_2 = Tk()
def vip_ck_gn(self):
self.txt1.insert(END, " 账号\t\t密码 \n")
for i in get_info('vips.txt'):
s = (i['账号'] + "\t\t" + i['密码'] + "\n")
self.txt1.insert(END, s)
def vip_ck_jm(self):
self.root_2.attributes('-alpha', -1)
root1 = Tk()
root1.geometry("600x400")
root1.title("查看")
lb = Label(root1, text='以下为所有会员信息', font=('宋体', 15))
lb.place(relx=0.1, rely=0.08, relwidth=0.8, relheight=0.1)
button_1 = Button(root1, text='查看', font=('宋体', 15), command=self.vip_ck_gn)
button_1.place(relx=0.35, rely=0.2, relwidth=0.3, relheight=0.1)
button_2 = Button(root1, text="返回", command=lambda: fanhui(self.root_2, root1))
button_2.place(relx=0.8, rely=0.3, relwidth=0.2, relheight=0.08)
self.txt1 = Text(root1, font=('宋体', 15))
self.txt1.place(rely=0.4, relheight=0.6)
root1.mainloop()
def orders_ck_gn(self):
for i in get_info('orders.txt'):
self.txt2.insert(END, "账号:" + i[0] + "\n")
self.txt2.insert(END, " 名称 单价*份数\n")
for j in range(1, len(i) - 3):
self.txt2.insert(END, i[j])
self.txt2.insert(END, "\n")
jg = i[-3:]
self.txt2.insert(END, "\t\t\t\t总价:{:.2f}\n".format(jg[0]))
self.txt2.insert(END, "\t\t\t\t折扣:{:.2f}\n".format(jg[1]))
self.txt2.insert(END, "\t\t\t\t实付:{:.2f}\n".format(jg[2]))
self.txt2.insert(END, "*" * 50 + "\n")
def orders_ck_jm(self):
self.root_2.attributes('-alpha', -1)
root2 = Tk()
root2.geometry("600x400")
root2.title("查看")
lb = Label(root2, text='以下为所有订单信息', font=('宋体', 15))
lb.place(relx=0.1, rely=0.08, relwidth=0.8, relheight=0.1)
button_1 = Button(root2, text='查看', font=('宋体', 15), command=self.orders_ck_gn)
button_1.place(relx=0.35, rely=0.2, relwidth=0.3, relheight=0.1)
button_2 = Button(root2, text="返回", command=lambda: fanhui(self.root_2, root2))
button_2.place(relx=0.8, rely=0.3, relwidth=0.2, relheight=0.08)
self.txt2 = Text(root2, font=('宋体', 15))
self.txt2.place(rely=0.4, relheight=0.6)
root2.mainloop()
def cd_ck_gn(self):
self.txt1_1.insert(END, " 名称\t\t单价 \n")
for i in get_info('menus.txt'):
s = (i['名称'] + "\t\t" + i['单价'] + "\n")
self.txt1_1.insert(END, s)
def cd_ck_jm(self):
root1_1 = Tk()
root1_1.geometry("600x400")
root1_1.title("查看")
lb = Label(root1_1, text='以下为所有菜品信息', font=('宋体', 15))
lb.place(relx=0.1, rely=0.08, relwidth=0.8, relheight=0.1)
button_1 = Button(root1_1, text='查看', font=('宋体', 15), command=self.cd_ck_gn)
button_1.place(relx=0.35, rely=0.2, relwidth=0.3, relheight=0.1)
button_2 = Button(root1_1, text="返回", command=lambda: zhuxiao(root1_1))
button_2.place(relx=0.8, rely=0.3, relwidth=0.2, relheight=0.08)
self.txt1_1 = Text(root1_1, font=('宋体', 15))
self.txt1_1.place(rely=0.4, relheight=0.6)
root1_1.mainloop()
def cd_tj_gn(self, a, b):
menu_1 = []
name = a.get()
price = b.get()
a.delete(0, END)
b.delete(0, END)
msgbox.showinfo('成功', '恭喜你添加成功!')
menu_1.append({'名称': name, '单价': price, })
with open('menus.txt', 'a', encoding='utf-8') as file:
for i in menu_1:
file.write(str(i) + '\n')
def cd_tj_jm(self):
self.root3.attributes('-alpha', -1)
root1_2 = Tk()
root1_2.geometry("600x400")
root1_2.title("添加")
name1_1 = Entry(root1_2, font=('宋体', 15))
name1_1.place(relx=0.3, rely=0.32, relwidth=0.5, relheight=0.1)
price1_1 = Entry(root1_2, font=('宋体', 15))
price1_1.place(relx=0.3, rely=0.52, relwidth=0.5, relheight=0.1)
name1 = Label(root1_2, text="请输入要添加的菜品:", font=('宋体', 15))
name1.place(relx=0.15, rely=0.15, relwidth=0.35, relheight=0.15)
name2 = Label(root1_2, text="名称:", font=('宋体', 15), width=10)
name2.place(relx=0.15, rely=0.3, relwidth=0.15, relheight=0.15)
name3 = Label(root1_2, text="单价:", font=('宋体', 15), width=10)
name3.place(relx=0.15, rely=0.5, relwidth=0.15, relheight=0.15)
button_1 = Button(root1_2, text="确认添加", font=('宋体', 15), command=lambda: self.cd_tj_gn(name1_1, price1_1))
button_1.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
button_2 = Button(root1_2, text='返回', command=lambda: fanhui(self.root3, root1_2))
button_2.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
root1_2.mainloop()
def cd_sc_gn(self, a):
cd_sc = get_info('menus.txt')
user = a.get()
a.delete(0, END)
for i in cd_sc:
if user == (i['名称']):
cd_sc.remove(i)
with open('menus.txt', 'w', encoding='utf-8') as file:
for j in cd_sc:
file.write(str(j) + '\n')
msgbox.showinfo('成功', '删除成功!')
break
else:
msgbox.showinfo('失败!', '请重新输入')
def cd_sc_jm(self):
self.root3.attributes('-alpha', -1)
root1_3 = Tk()
root1_3.geometry("600x400")
root1_3.title("删除")
name1_3 = Entry(root1_3, font=('宋体', 15))
name1_3.place(relx=0.3, rely=0.32, relwidth=0.5, relheight=0.1)
name1 = Label(root1_3, text="请输入要删除的菜品:", font=('宋体', 15))
name1.place(relx=0.15, rely=0.15, relwidth=0.35, relheight=0.15)
name2 = Label(root1_3, text="用户名:", font=('宋体', 15), width=10)
name2.place(relx=0.15, rely=0.3, relwidth=0.15, relheight=0.15)
button_1 = Button(root1_3, text="删除", font=('宋体', 15), command=lambda: self.cd_sc_gn(name1_3))
button_1.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
button_2 = Button(root1_3, text='返回', command=lambda: fanhui(self.root3, root1_3))
button_2.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
root1_3.mainloop()
def cd_jm(self):
self.root_2.attributes('-alpha', -1)
self.root3 = Tk()
self.root3.geometry("600x400")
self.root3.title("菜单管理")
lb1_1 = Label(self.root3, text='请点击功能', font=('宋体', 15))
lb1_1.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.2)
btn1_1 = Button(self.root3, text='查看', font=('宋体', 15), command=self.cd_ck_jm)
btn1_1.place(relx=0.3, rely=0.3, relwidth=0.4, relheight=0.15)
btn1_2 = Button(self.root3, text='添加', font=('宋体', 15), command=self.cd_tj_jm)
btn1_2.place(relx=0.3, rely=0.5, relwidth=0.4, relheight=0.15)
btn1_3 = Button(self.root3, text='删除', font=('宋体', 15), command=self.cd_sc_jm)
btn1_3.place(relx=0.3, rely=0.7, relwidth=0.4, relheight=0.15)
btn1_4 = Button(self.root3, text='返回', command=lambda: fanhui(self.root_2, self.root3))
btn1_4.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root3.mainloop()
def windows(self):
self.root_2.geometry("600x400")
self.root_2.title("后台管理")
lb1_1 = Label(self.root_2, text='请点击功能', font=('宋体', 15))
lb1_1.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.2)
btn1_1 = Button(self.root_2, text='会员查看', font=('宋体', 15), command=self.vip_ck_jm)
btn1_1.place(relx=0.35, rely=0.3, relwidth=0.3, relheight=0.15)
btn1_2 = Button(self.root_2, text='订单查看', font=('宋体', 15), command=self.orders_ck_jm)
btn1_2.place(relx=0.35, rely=0.5, relwidth=0.3, relheight=0.15)
btn1_3 = Button(self.root_2, text='菜单管理', font=('宋体', 15), command=self.cd_jm)
btn1_3.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
btn1_4 = Button(self.root_2, text='返回', command=lambda: fanhui(root, self.root_2))
btn1_4.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root_2.mainloop()
class Ordor():
def __init__(self):
self.root_3 = Tk()
def qk(self):
self.txt3_2.delete(2.0, END)
user = self.dd[0]
self.dd.clear()
self.dd.append(user)
def dc(self):
self.dd.append(self.money)
if self.vip == 1:
savemoney = self.money * 0.1
finally_money = self.money * 0.9
else:
savemoney = 0
finally_money = self.money
self.dd.append(savemoney)
self.dd.append(finally_money)
with open('orders.txt', 'a', encoding='utf-8') as file:
file.write(str(self.dd) + "\n")
self.root4 = Tk()
self.root4.geometry("600x400")
self.root4.title("下单成功")
self.txt4_1 = Text(self.root4, font=('宋体', 15))
self.txt4_1.place(relx=0.05, rely=0.05, relwidth=0.8, relheight=0.7)
self.txt4_1.insert(END, "账号:" + self.dd[0] + "\n")
self.txt4_1.insert(END, " 名称 单价*份数\n")
for i in range(1, len(self.dd) - 3):
self.txt4_1.insert(END, self.dd[i])
self.txt4_1.insert(END, "\n")
jg = self.dd[-3:]
self.txt4_1.insert(END, "\t\t\t\t总价:{:.2f}\n".format(jg[0]))
self.txt4_1.insert(END, "\t\t\t\t折扣:{:.2f}\n".format(jg[1]))
self.txt4_1.insert(END, "\t\t\t\t实付:{:.2f}\n".format(jg[2]))
self.qk()
button_2 = Button(self.root4, text='确认', font=('宋体', 15), command=lambda: zhuxiao(self.root4))
button_2.place(relx=0.8, rely=0.8, relwidth=0.2, relheight=0.15)
zhuxiao(self.root3)
def tj(self):
txt = []
xh = self.xh.get()
number = self.number.get()
self.xh.delete(0, END)
self.number.delete(0, END)
self.txt3_2.insert(END, "\n" + get_info('menus.txt')[int(str(xh)) - 1]['名称'] + " ")
self.txt3_2.insert(END, get_info('menus.txt')[int(str(xh)) - 1]['单价'] + " ")
self.txt3_2.insert(END, number)
self.money = self.money + int(get_info('menus.txt')[int(str(xh)) - 1]['单价']) * int(number)
txt.append(get_info('menus.txt')[int(str(xh)) - 1]['名称'])
txt.append(get_info('menus.txt')[int(str(xh)) - 1]['单价'])
txt.append(number)
self.dd.append(txt)
def jm(self):
self.root3 = Tk()
self.root3.geometry("600x400")
self.root3.title("点餐服务")
lb = Label(self.root3, text='本店菜单如下', font=('宋体', 15))
lb.place(relx=0.05, rely=0.08, relwidth=0.3, relheight=0.1)
self.txt3_1 = Text(self.root3)
self.txt3_1.place(relx=0.05, rely=0.2, relwidth=0.3, relheight=0.6)
self.txt3_1.insert(END, "序号\t名称\t 单价\n")
xh = 0
self.money = 0
for i in get_info('menus.txt'):
xh += 1
s = (i['名称'] + "\t\t" + i['单价'] + "\n")
d = (" " + str(xh) + " " + s)
self.txt3_1.insert(END, d)
name1 = Label(self.root3, text="菜品序号:", font=('宋体', 15), width=10)
name1.place(relx=0.4, rely=0.15, relwidth=0.18, relheight=0.1)
self.xh = Entry(self.root3, font=('宋体', 15))
self.xh.place(relx=0.6, rely=0.16, relwidth=0.25, relheight=0.1)
name2 = Label(self.root3, text="份数:", font=('宋体', 15), width=10)
name2.place(relx=0.45, rely=0.29, relwidth=0.18, relheight=0.1)
self.number = Entry(self.root3, font=('宋体', 15))
self.number.place(relx=0.6, rely=0.3, relwidth=0.25, relheight=0.1)
button_1 = Button(self.root3, text='清空', font=('宋体', 15), command=self.qk)
button_1.place(relx=0.5, rely=0.45, relwidth=0.12, relheight=0.1)
button_2 = Button(self.root3, text='添加', font=('宋体', 15), command=self.tj)
button_2.place(relx=0.7, rely=0.45, relwidth=0.12, relheight=0.1)
self.txt3_2 = Text(self.root3)
self.txt3_2.place(relx=0.45, rely=0.58, relwidth=0.45, relheight=0.2)
self.txt3_2.insert(END, " 名称\t\t单价\t份数")
button_3 = Button(self.root3, text='确认点餐', font=('宋体', 15), command=self.dc)
button_3.place(relx=0.6, rely=0.8, relwidth=0.2, relheight=0.1)
button_4 = Button(self.root3, text="返回", command=lambda: zhuxiao(self.root3))
button_4.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root3.mainloop()
def dl_gn(self, a, b):
self.vip = 1
vip_user = a.get()
self.dd = []
self.dd.append(vip_user)
passwd = b.get()
for i in get_info('vips.txt'):
if vip_user == (i['账号']) and passwd == (i['密码']):
zhuxiao(self.root1)
self.jm()
break
else:
msgbox.showinfo('失败!', '请重新输入')
def vip_jm(self):
self.root1 = Tk()
self.root1.geometry("600x400")
self.root1.title("登录")
vip_name = Entry(self.root1, font=('宋体', 15))
vip_name.place(relx=0.3, rely=0.32, relwidth=0.5, relheight=0.1)
passwd = Entry(self.root1, show="*", font=('宋体', 15))
passwd.place(relx=0.3, rely=0.52, relwidth=0.5, relheight=0.1)
name1 = Label(self.root1, text="请登录:", font=('宋体', 15))
name1.place(relx=0.15, rely=0.15, relwidth=0.35, relheight=0.15)
name2 = Label(self.root1, text="账号:", font=('宋体', 15), width=10)
name2.place(relx=0.15, rely=0.3, relwidth=0.15, relheight=0.15)
name3 = Label(self.root1, text="密码:", font=('宋体', 15), width=10)
name3.place(relx=0.15, rely=0.5, relwidth=0.15, relheight=0.15)
button_1 = Button(self.root1, text="登录", font=('宋体', 15), command=lambda: self.dl_gn(vip_name, passwd))
button_1.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
button_2 = Button(self.root1, text='返回', command=lambda: zhuxiao(self.root1))
button_2.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root1.mainloop()
def not_vip_gn(self, a):
self.vip = 0
self.not_Vipuser = a.get()
self.dd = []
self.dd.append(self.not_Vipuser)
zhuxiao(self.root2)
self.jm()
def not_vip_jm(self):
self.root2 = Tk()
self.root2.geometry("600x400")
self.root2.title("账号:")
not_vip_name = Entry(self.root2, font=('宋体', 15))
not_vip_name.place(relx=0.3, rely=0.32, relwidth=0.5, relheight=0.1)
name1 = Label(self.root2, text="请输入手机号:", font=('宋体', 15))
name1.place(relx=0.15, rely=0.15, relwidth=0.35, relheight=0.15)
button_1 = Button(self.root2, text="确定", font=('宋体', 15), command=lambda: self.not_vip_gn(not_vip_name))
button_1.place(relx=0.35, rely=0.7, relwidth=0.3, relheight=0.15)
button_2 = Button(self.root2, text='返回', command=lambda: zhuxiao(self.root2))
button_2.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root2.mainloop()
def windows(self):
self.root_3.geometry("600x400")
self.root_3.title("点餐服务")
lb1_1 = Label(self.root_3, text='请选择', font=('宋体', 15))
lb1_1.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.2)
btn1_1 = Button(self.root_3, text='我是会员', font=('宋体', 15), command=self.vip_jm)
btn1_1.place(relx=0.2, rely=0.35, relwidth=0.6, relheight=0.15)
btn1_2 = Button(self.root_3, text='我不是会员', font=('宋体', 15), command=self.not_vip_jm)
btn1_2.place(relx=0.2, rely=0.6, relwidth=0.6, relheight=0.15)
btn1_3 = Button(self.root_3, text='返回注册', command=lambda: fanhui(root, self.root_3))
btn1_3.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
self.root_3.mainloop()
if __name__ == '__main__':
root = Tk()
root.geometry('800x600')
root.title('欢迎光临C.餐厅')
lb1 = Label(root, text='请点击功能', font=('宋体', 15))
lb1.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.2)
btn1 = Button(root, text='会员服务', font=('宋体', 20), command=lambda: run1(root))
btn1.place(relx=0.25, rely=0.3, relwidth=0.5, relheight=0.15)
btn2 = Button(root, text='后台管理', font=('宋体', 20), command=lambda: dl_rest_jm(root))
btn2.place(relx=0.25, rely=0.5, relwidth=0.5, relheight=0.15)
btn3 = Button(root, text='点餐服务', font=('宋体', 20), command=lambda: run3(root))
btn3.place(relx=0.25, rely=0.7, relwidth=0.5, relheight=0.15)
btn4 = Button(root, text='退出', command=lambda: zhuxiao(root))
btn4.place(relx=0.85, rely=0.9, relwidth=0.15, relheight=0.08)
root.mainloop()
Gitte源码仓库: