-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu_insert.py
More file actions
226 lines (195 loc) · 11.5 KB
/
menu_insert.py
File metadata and controls
226 lines (195 loc) · 11.5 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
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
import tkinter
import tkinter.ttk
import tkinter.font
import tkinter.messagebox
from tkinter import *
import datetime
import random
import pymysql
import receipt
import numPeople
class Menuinsert:
def __init__(self, menu, n):
self.menu = menu
self.personnum = n
self.personname = [0, 0, 0, 0, 0, 0]
self.personmenu = [0, 0, 0, 0, 0, 0]
self.persontotal =[0, 0, 0, 0, 0, 0]
# 배경 설정
self.menuBack = tkinter.PhotoImage(file="image/white.png")
self.menuBackL = tkinter.Label(image=self.menuBack)
self.menuBackL.place(x=-2, y=-2)
# 폰트 설정
fonts = tkinter.font.Font(size=11, weight='bold')
fontm = tkinter.font.Font(size=13, weight='bold')
# 장소 입력
self.locationText = Label(menu, text='장소', width=6, bg="white", font=fontm, fg='#ff7878')
self.locationText.place(x=100, y=70)
# 입력수에 제한받지 않고 필수로 나타나는 칸
# 위치 입력칸
self.inputLocation = Entry(self.menu, width=23, font=fonts, relief="groove", highlightthickness=2,
highlightbackground="#8294cd")
self.inputLocation.place(x=100, y=100)
# 뒤로 가기 버튼
self.backButton = Button(self.menu, width=4, text='⇦', repeatdelay=20, bg='#ff7878', font=fontm,
fg="white", command=self.moveTonumPeople) # command=self.to_receipt,
self.backButton.place(x=20, y=25)
# 도움말 버튼
self.infoButton = Button(self.menu, width=5, text='도움말', repeatdelay=20, bg='#ff7878', font=fontm,
fg="white", command=self.Msgbox) # command=self.to_receipt,
self.infoButton.place(x=800, y=25)
# 메뉴 입력
self.menuText = Label(self.menu, text='더치페이 할 품목', width=20, bg="white", font=fontm, fg='#ff7878')
self.menuText.place(x=65, y=140)
self.inputMenu = Entry(self.menu, width=80, font=fonts, relief="groove", highlightthickness=2,
highlightbackground="#8294cd")
self.inputMenu.place(x=100, y=170)
# 이름 입력
self.locationText = Label(self.menu, text='이름', width=10, bg="white", font=fontm, fg='#ff7878')
self.locationText.place(x=70, y=210) # 410
# 사람1
self.personname[1 - 1] = Entry(self.menu, width=20, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 사람2
self.personname[2 - 1] = Entry(self.menu, width=20, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 사람3
self.personname[3 - 1] = Entry(self.menu, width=20, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 사람4
self.personname[4 - 1] = Entry(self.menu, width=20, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 사람5
self.personname[5 - 1] = Entry(self.menu, width=20, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 사람6
self.personname[6 - 1] = Entry(self.menu, width=20, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 사람 수 만큼 칸 보여주기
for i in range(0, self.personnum):
self.personname[i].place(x=100, y=220 + 30 * (i + 1))
# 메뉴 가격
self.priceText = Label(self.menu, text='개인 메뉴 가격', width=10, bg="white", font=fontm, fg='#ff7878')
self.priceText.place(x=330, y=210) # 410
# 메뉴1
self.personmenu[1 - 1] = Entry(self.menu, width=50, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 메뉴2
self.personmenu[2 - 1] = Entry(self.menu, width=50, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 메뉴3
self.personmenu[3 - 1] = Entry(self.menu, width=50, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 메뉴4
self.personmenu[4 - 1] = Entry(self.menu, width=50, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 메뉴5
self.personmenu[5 - 1] = Entry(self.menu, width=50, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 메뉴6
self.personmenu[6 - 1] = Entry(self.menu, width=50, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
# 단체메뉴
self.groupmenuText = Label(self.menu, text='단체메뉴 가격', width=10, bg="white", font=fontm, fg='#ff7878')
self.groupmenuText.place(x=100, y=450)
# 단체메뉴
self.groupmenu = Entry(self.menu, width=55, font=fonts, relief="groove", bg='white', fg='black',
highlightthickness=1, highlightbackground="#8294cd")
self.groupmenu.place(x=100, y=500)
# 사람 수 만큼 메뉴칸 보여주기
for i in range(0, self.personnum):
self.personmenu[i].place(x=330, y=220 + 30 * (i + 1))
# 반올림
self.updown = Label(self.menu, text='반올림 단위 ', width=10, bg="white", font=fontm, fg='#ff7878')
self.updown.place(x=100, y=550)
# 라디오 버튼
self.RadioVariety_1 = tkinter.IntVar()
self.rd1 = Radiobutton(self.menu, text="10", bg="white", font=fontm, fg='#ff7878', value=1,
variable=self.RadioVariety_1)
self.rd1.place(x=100, y=600)
self.rd2 = Radiobutton(self.menu, text="100", bg="white", font=fontm, fg='#ff7878', value=2,
variable=self.RadioVariety_1)
self.rd2.place(x=200, y=600)
self.rd3 = Radiobutton(self.menu, text="1000", bg="white", font=fontm, fg='#ff7878', value=3,
variable=self.RadioVariety_1)
self.rd3.place(x=300, y=600)
self.rd4 = Radiobutton(self.menu, text="10000", bg="white", font=fontm, fg='#ff7878', value=4,
variable=self.RadioVariety_1)
self.rd4.place(x=400, y=600)
self.rd5 = Radiobutton(self.menu, text="반올림 안 함", bg="white", font=fontm, fg='#ff7878', value=5,
variable=self.RadioVariety_1)
self.rd5.place(x=500, y=600)
# 저장 버튼
self.saveButton = Button(self.menu, width=30, text='G O !', repeatdelay=20, bg='#ff7878',
font=fontm, fg="white", command=self.save) # command=self.to_receipt,
self.saveButton.place(x=300, y=650)
def moveTonumPeople(self):
Move = numPeople.NumPeople(self.menu)
def play(self):
self.menu.mainloop()
def Msgbox(self):
tkinter.messagebox.showinfo("도움말", "1.이름 밑 칸에는 이름을 입력해주세요."
"\n2.가격을 입력하실 때에는 첫번째칸부터 '/'로 가격을 나누어서 꼭 모두 입력해주세요. "
"\n3.단체메뉴 가격도 '/'로 가격을 나누어서 입력해주세요."
"\n4.입력을 끝냈다면 GO! 버튼을 눌러주세요.")
def save(self):
for i in range(0, self.personnum):
if not self.personname[0].get():
tkinter.messagebox.showinfo("이름 입력", "모든 사람의 이름을 입력해주세요.")
break
if not self.personmenu[i].get():
tkinter.messagebox.showinfo("개인메뉴 가격 입력", "모든 개인메뉴 가격을 입력해주세요."
"\n개임메뉴가격이 없는 경우 0을 입력해주세요")
break
if not self.groupmenu.get():
tkinter.messagebox.showinfo("그룹메뉴 가격 입력", "그룹메뉴 가격을 입력해주세요."
"\n그룹메뉴가격이 없는 경우 0을 입력해주세요")
break
else:
self.ID = random.randint(1, 1000)
self.now = datetime.datetime.utcnow()
sqlCon = pymysql.connect(host="127.0.0.1", user="root", password="goodday0722", database="dutchdb",
charset="utf8")
cur = sqlCon.cursor(pymysql.cursors.DictCursor)
cur.execute(
"INSERT INTO dutchdb VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
(
self.ID,
self.now.strftime('%Y-%m-%d %H:%M:%S'),
self.personnum, # 명수
self.personname[1 - 1].get(), # 이름1
self.personname[2 - 1].get(), # 이름2
self.personname[3 - 1].get(), # 이름3
self.personname[4 - 1].get(), # 이름4
self.personname[5 - 1].get(), # 이름5
self.personname[6 - 1].get(), # 이름6
self.personmenu[1 - 1].get(), # 메뉴1
self.personmenu[2 - 1].get(), # 메뉴2
self.personmenu[3 - 1].get(), # 메뉴3
self.personmenu[4 - 1].get(), # 메뉴4
self.personmenu[5 - 1].get(), # 메뉴5
self.personmenu[6 - 1].get(), # 메뉴6
self.groupmenu.get(),
self.inputLocation.get(), # 장소
self.inputMenu.get(), # 그룹메뉴가격
self.RadioVariety_1.get()
))
sqlCon.commit()
sqlCon.close()
inputm = [self.inputLocation.get(), self.inputMenu.get(),
[self.personname[1 - 1].get(), self.personmenu[1 - 1].get()],
[self.personname[2 - 1].get(), self.personmenu[2 - 1].get()],
[self.personname[3 - 1].get(), self.personmenu[3 - 1].get()],
[self.personname[4 - 1].get(), self.personmenu[4 - 1].get()],
[self.personname[5 - 1].get(), self.personmenu[5 - 1].get()],
[self.personname[6 - 1].get(), self.personmenu[6 - 1].get()],
self.groupmenu.get(), self.RadioVariety_1.get()]
Move = receipt.Receipt(self.menu, inputm, self.personnum, self.ID)
break
if __name__ == '__main__':
menu = tkinter.Tk()
menu.title("더치 페이")
menu.geometry("900x700+100+100")
menu.resizable(False, False)
re = Menuinsert(menu)
re.play()