-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtkinter_drink_order2.py
More file actions
162 lines (115 loc) · 5.21 KB
/
tkinter_drink_order2.py
File metadata and controls
162 lines (115 loc) · 5.21 KB
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
import tkinter as tk
price_meal = {"김밥": 3000, "라면": 3500, "떡볶이": 5000, "튀김": 5000, "쫄면": 7000}
price_drink = {"아메리카노": 3000, "라떼": 3500, "아이스티": 4000, "레몬에이드": 4500, "딸기스무디": 5000}
order_meal = {}
order_drink = {}
total_price = 0
def show_meal():
btn_meal.configure(bg="yellow")
btn_drink.configure(bg="white")
frame4.pack_forget()
frame3.pack_forget()
frame2.pack(fill="both", expand=True)
frame4.pack(fill="both", expand=True)
def show_drink():
btn_meal.configure(bg="white")
btn_drink.configure(bg="yellow")
frame4.pack_forget()
frame2.pack_forget()
frame3.pack(fill="both", expand=True)
frame4.pack(fill="both", expand=True)
def meal_add(m):
global price_meal, order_meal, total_price
if m not in price_meal:
print("입력한 메뉴가 존재하지 않습니다.")
this_price = price_meal.get(m)
total_price += this_price
if m in order_meal:
order_meal[m] = order_meal.get(m) + 1
else:
order_meal[m] = 1
print_order()
print_price()
def drink_add(m):
global price_meal, order_meal, total_price
if m not in price_drink:
print("입력한 메뉴가 존재하지 않습니다.")
this_price = price_drink.get(m)
total_price += this_price
if m in order_drink:
order_drink[m] = order_drink.get(m) + 1
else:
order_drink[m] = 1
print_order()
print_price()
def print_order():
global order_meal, order_drink
tmp = ""
price_tmp = 0
for i in order_meal:
price_tmp = price_meal[i] * order_meal.get(i)
tmp = tmp + i + " X " + str(order_meal.get(i)) + " = " + str(price_tmp)+"\n"
for i in order_drink:
price_tmp = price_drink[i] * order_drink.get(i)
tmp = tmp + i + " X " + str(order_drink.get(i)) + " = " + str(price_tmp)+"\n"
text_1.delete('1.0', tk.END)
text_1.insert(tk.INSERT, tmp)
def order_end():
global total_price, order_meal, order_drink
total_price = 0
del order_meal
del order_drink
order_meal = {}
order_drink = {}
print_price()
print_order()
show_meal()
def print_price():
global total_price
label_price.configure(text=str(total_price)+" 원")
window = tk.Tk()
window.title("주문 프로그램")
window.geometry("600x400+500+300")
window.resizable(False, False)
frame1 = tk.Frame(window, width="600", height="10")
frame1.pack(fill="both")
frame2 = tk.Frame(window, width="600")
frame2.pack(fill="both", expand=True)
frame3 = tk.Frame(window, width="600")
# frame3.pack(fill="both", expand=True)
frame4 = tk.Frame(window, width="600", height="10")
frame4.pack(fill="both", expand=True)
btn_meal = tk.Button(frame1, text="식사", padx="10", pady="10", bg="yellow", command=show_meal)
btn_meal.grid(row=0, column=0, padx=10, pady=10)
btn_drink = tk.Button(frame1, text="음료", padx="10", pady="10", bg="white", command=show_drink)
btn_drink.grid(row=0, column=1, padx=10, pady=10)
btn_end = tk.Button(frame1, text="주문종료", padx="10", pady="10", command=order_end)
btn_end.grid(row=0, column=2, padx=10, pady=10)
label_price = tk.Label(frame1, text="0 원", width="20", padx=10, pady="10", fg="blue", font='Arial 15')
label_price.grid(row=0, column="3", padx="10", pady="10")
# 식사
btn_meal_1 = tk.Button(frame2, text="김밥\n(3000원)", padx="10", pady="10", width="10", command=lambda: meal_add('김밥'))
btn_meal_1.grid(row=0, column=0, padx=10, pady=10)
btn_meal_2 = tk.Button(frame2, text="라면\n(3500원)", padx="10", pady="10", width="10", command=lambda: meal_add('라면'))
btn_meal_2.grid(row=0, column=1, padx=10, pady=10)
btn_meal_3 = tk.Button(frame2, text="떡볶이\n(5000원)", padx="10", pady="10", width="10", command=lambda: meal_add('떡볶이'))
btn_meal_3.grid(row=0, column=2, padx=10, pady=10)
btn_meal_4 = tk.Button(frame2, text="튀김\n(5000원)", padx="10", pady="10", width="10", command=lambda: meal_add('튀김'))
btn_meal_4.grid(row=0, column=3, padx=10, pady=10)
btn_meal_5 = tk.Button(frame2, text="쫄면\n(7000원)", padx="10", pady="10", width="10", command=lambda: meal_add('쫄면'))
btn_meal_5.grid(row=0, column=4, padx=10, pady=10)
# 음료
btn_drink_1 = tk.Button(frame3, text="아메리카노\n(3000원)", padx="10", pady="10", width="10", command=lambda: drink_add('아메리카노'))
btn_drink_1.grid(row=0, column=0, padx=10, pady=10)
btn_drink_2 = tk.Button(frame3, text="라떼\n(3500원)", padx="10", pady="10", width="10", command=lambda: drink_add('라떼'))
btn_drink_2.grid(row=0, column=1, padx=10, pady=10)
btn_drink_3 = tk.Button(frame3, text="아이스티\n(4000원)", padx="10", pady="10", width="10", command=lambda: drink_add('아이스티'))
btn_drink_3.grid(row=0, column=2, padx=10, pady=10)
btn_drink_4 = tk.Button(frame3, text="레몬에이드\n(4500원)", padx="10", pady="10", width="10", command=lambda: drink_add('레몬에이드'))
btn_drink_4.grid(row=0, column=3, padx=10, pady=10)
btn_drink_5 = tk.Button(frame3, text="딸기스무디\n(5000원)", padx="10", pady="10", width="10", command=lambda: drink_add('딸기스무디'))
btn_drink_5.grid(row=0, column=4, padx=10, pady=10)
# 주문 리스트
text_1 = tk.Text(frame4, height="10")
text_1.pack()
window.mainloop()