from tkinter import *
import tkinter as tk
from tkinter import messagebox
# from tkinter import Messagebox
window = tk.Tk()
window.title("음료수준")
window.geometry("500x500")
price = {'coffee':3500,"lette":4000,"smoothie":4500,"tea":300}
order=[]
sum = 0
menu_no=0
def add(item):
global sum
global menu_no
if item not in price:
print("no Drink")
this_price = price.get(item)
sum += this_price
order.append(item)
menu_no = menu_no + 1
textarea.insert(tk.INSERT, f' {menu_no} 번==>'+ item+'\n ')
Label1["text"]=f"금액:"+ str(sum)+"원"
def btn_exit():
msgbox = tk.messagebox.askquestion('확인',"주문을 마치시겠습니까?")
if msgbox == "yes":
exit()
frame1 = tk.Frame(window)
frame1.pack()
tk.Button(frame1,text="coffee", command=lambda:add('coffee'),width=10,height=2).grid(row=0,column=0)
tk.Button(frame1,text="lette", command=lambda:add('lette'),width=10,height=2).grid(row=0,column=1)
tk.Button(frame1,text="smothie", command=lambda:add('smoothie'),width=10,height=2).grid(row=0,column=2)
tk.Button(frame1,text="tea", command=lambda:add('tea'),width=10,height=2).grid(row=0,column=3)
tk.Button(frame1,text="exit", command=btn_exit,width=10,height=2).grid(row=0,column=4)
Label1 = tk.Label(window,text="금액:0원", width=100, height=2,fg="blue")
Label1.pack()
textarea = tk.Text(window)
textarea.pack()
window.mainloop()