-
Notifications
You must be signed in to change notification settings - Fork 0
/
first1.py
477 lines (416 loc) · 16.7 KB
/
first1.py
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
from tkinter import *
import os
import sqlite3
import numpy as np
def register():
global rs
rs = Toplevel(ms)
rs.geometry("500x500")
rs.title("Register")
global username
global password
global username_entry
global password_entry
global name
global age
global phone_no
global name_entry
global phone_entry
global age_entry
username = StringVar()
password = StringVar()
name=StringVar()
age=StringVar()
phone_no=StringVar()
Label(rs, text="Please enter the details ", bg="blue").pack(fill=X)
Label(rs, text="").pack()
username_lable = Label(rs, text="Username : ")
username_lable.pack()
username_entry = Entry(rs, textvariable=username)
username_entry.pack()
password_lable = Label(rs, text="Password : ")
password_lable.pack()
password_entry = Entry(rs, textvariable=password, show='*')
password_entry.pack()
Label(rs, text="please enter the personal details",bg="blue").pack(fill=X)
Label(rs,text=" ").pack()
Label(rs,text="Name: ").pack()
name_entry=Entry(rs,textvariable=name)
name_entry.pack()
Label(rs,text="Age: ").pack()
age_entry=Entry(rs,textvariable=age)
age_entry.pack()
Label(rs,text=":Phone no: ").pack()
phone_entry=Entry(rs,textvariable=phone_no)
phone_entry.pack()
Label(rs,text=" ").pack()
Button(rs, text="Register", height=1, bg="blue", command = register_user).pack()
def login():
global ls
ls = Toplevel(ms,bg="white")
ls.geometry("500x500")
ls.title("Login")
Label(ls,bg="white",text="Please enter the details login").pack(fill="x")
Label(ls,bg="white", text="").pack()
global uv
global pv
uv = StringVar()
pv = StringVar()
global username_login_entry
global password_login_entry
Label(ls,bg="white", text="Username * ").pack()
username_login_entry = Entry(ls, textvariable=uv)
username_login_entry.pack()
Label(ls,bg="white", text="").pack()
Label(ls,bg="white", text="Password * ").pack()
password_login_entry = Entry(ls, textvariable=pv, show= '*')
password_login_entry.pack()
Label(ls,bg="white", text="").pack()
Button(ls,bg="black",fg="blue", text="Login",height=1, command = login_verify).pack()
def register_user():
global username_info
global password_info
global name_info
global age_info
global phone_info
username_info = username.get()
password_info = password.get()
name_info=name.get()
age_info=age.get()
phone_info=phone_no.get()
file = open(username_info, "w")
file.write(username_info + "\n")
file.write(password_info+ "\n")
file.write(age_info+ "\n")
file.write(name_info+"\n")
file.write(phone_info+"\n")
file.close()
username_entry.delete(0, END)
password_entry.delete(0, END)
Label(rs, text="Registration Success", fg="green", font=("calibri", 11)).pack()
rs.destroy()
def login_verify():
global username1
global password1
username1 = uv.get()
password1 = pv.get()
username_login_entry.delete(0, END)
password_login_entry.delete(0, END)
list_of_files = os.listdir()
if username1 in list_of_files:
file1 = open(username1, "r")
verify = file1.read().splitlines()
if password1 in verify:
ls.destroy()
restaurant()
else:
password_not_recognised()
else:
user_not_found()
def password_not_recognised():
global password_not_recog_screen
password_not_recog_screen = Toplevel(ls)
password_not_recog_screen.title("Success")
Label(password_not_recog_screen, text="Invalid Password ").pack()
Button(password_not_recog_screen, text="OK", command=delete_password_not_recognised).pack()
def user_not_found():
global user_not_found_screen
user_not_found_screen = Toplevel(ls)
user_not_found_screen.title("Success")
Label(user_not_found_screen, text="User Not Found").pack()
Button(user_not_found_screen, text="OK", command=delete_user_not_found_screen).pack()
def delete_password_not_recognised():
password_not_recog_screen.destroy()
def delete_user_not_found_screen():
user_not_found_screen.destroy()
def restaurant():
top=Toplevel(ms)
top.geometry("500x500")
Label(top, text="Please enter the details login",height="5",bg="blue").pack(fill="x")
Label(top, text="").pack()
Button(top,text=" OM SWEETS",height="2",width="30",bg="white",command=ok).pack()
Button(top,text="QUALITY DHABA",height="2",width="30",bg="white",command=ok).pack()
Button(top,text="DAANA PANI",height="2",width="30",bg="white",command=ok).pack()
Button(top,text="SUKHDEV",height="2",width="30",bg="white",command=ok).pack()
Button(top,text="MANNAT",height="2",width="30",bg="white",command=ok).pack()
Button(top,text="HASHTAG",height="2",width="30",bg="white",command=ok).pack()
Button(top,text="HUNGRY",height="2",width="30",bg="white",command=ok).pack()
Button(top,text="TIKKA POINT",height="2",width="30",bg="white",command=ok).pack()
def ok():
global jk
global item
jk=Toplevel(ms)
jk.geometry("1800x900")
Label(jk,text="MENU",height="3",width="1000",font=("calibri",18),bg="light green").pack(fill="x")
def IND():
label1=Label(jk,text="SELECT ITEM",bg="blue",fg="red",font=("bold",30))
label1.pack(fill="x")
lb=Listbox(jk,width=130,height=34)
lb.insert(1,"1 SAMOSA ________________________________________ 25")
lb.insert(2,"2 DOSA __________________________________________ 100")
lb.insert(3,"3 KACHORI _______________________________________ 20")
lb.insert(4,"4 ALOO PARATHA __________________________________ 50")
lb.insert(5,"5 PLAIN PARATHA _________________________________ 30")
lb.insert(6,"6 PANEER PARATHA ________________________________ 60")
lb.place(x=300,y=90)
def function4():
clicked_item=lb.curselection()
item=lb.get(clicked_item)
advise()
learning(item)
Button(jk,text="SELECT",height="5",width="20",bg="red",fg="blue",command=function4).pack()
def bevg():
label1=Label(jk,text="SELECT ITEM",bg="blue",fg="red",font=("bold",30))
label1.pack(fill="x")
lb=Listbox(jk,width=130,height=34)
lb.insert(1,"1 COFFEE ________________________________________ 15")
lb.insert(2,"2 TEA __________________________________________ 10")
lb.insert(3,"3 PEPSI _______________________________________ 35")
lb.insert(4,"4 COLD COFFEE __________________________________ 50")
lb.place(x=300,y=90)
def function4():
clicked_item=lb.curselection()
item=lb.get(clicked_item)
advise()
learning(item)
Button(jk,text="SELECT",height="5",width="20",bg="red",fg="blue",command=function4).pack()
def DST():
label1=Label(jk,text="SELECT ITEM",bg="blue",fg="red",font=("bold",30))
label1.pack(fill="x")
lb=Listbox(jk,width=130,height=34,selectmode="multiple")
lb.insert(1,"1 GULAB JAMUN ________________________________ 25")
lb.insert(2,"2 ICECREAM ___________________________________100")
lb.insert(3,"3 CAKE _______________________________________ 20")
lb.place(x=300,y=90)
def function4():
clicked_item=lb.curselection()
item=lb.get(clicked_item)
advise()
learning(item)
Button(jk,text="SELECT",height="5",width="20",bg="red",fg="blue",command=function4).pack()
def SNK():
label1=Label(jk,text="SELECT ITEM",bg="blue",fg="red",font=("bold",30))
label1.pack(fill="x")
lb=Listbox(jk,width=130,height=34,selectmode="multiple")
lb.insert(1,"1 VEG BURGER ________________________________________ 25")
lb.insert(2,"2 CHICKEN BURGER____________________________________ 100")
lb.insert(3,"3 SPRING ROLL _______________________________________ 20")
lb.insert(4,"4 ALOO PARATHA __________________________________ 50")
lb.place(x=300,y=90)
def function4():
clicked_item=lb.curselection()
item=lb.get(clicked_item)
advise()
learning(item)
Button(jk,text="SELECT",height="5",width="20",bg="red",fg="blue",command=function4).pack()
Label(jk,height="200",width="200",image=snacks).place(x=20,y=100)
Label(jk,height="200",width="200",image=beverage).place(x=500,y=100)
Button(jk,text="Beverages",height="5",width="26",bg="white",command=bevg).place(x=500,y=310)
Button(jk,text="Snacks",height="5",width="26",bg="white",command=SNK).place(x=20,y=310)
Label(jk,height="200",width="200",image=desert).place(x=1000,y=100)
Button(jk,text="desert",height="5",width="26",bg="white",command=DST).place(x=1000,y=310)
Label(jk,height="200",width="200",image=indian).place(x=500,y=450)
Button(jk,text="indian",height="5",width="26",bg="white",command=IND).place(x=500,y=660)
def advise():
global adv
global ansv
global itemb
ansv=StringVar()
adv=Toplevel(ms)
adv.geometry("1800x900")
Label(adv,text="People also baught").pack(fill=X)
Entry(adv,textvariable=ansv).pack(fill=X)
Label(adv,text=" ").pack()
label1=Label(adv,text="SELECT Beverage",bg="blue",fg="red",font=("bold",30)).pack(fill=X)
lb=Listbox(adv,width=130,height=34)
lb.insert(1,"1 COFFEE ________________________________________ 15")
lb.insert(2,"2 TEA __________________________________________ 10")
lb.insert(3,"3 PEPSI _______________________________________ 35")
lb.insert(4,"4 COLD COFFEE __________________________________ 50")
lb.place(x=300,y=90)
def function4():
clicked_item=lb.curselection()
itemb=lb.get(clicked_item)
perform(itemb)
Label(adv,text=" ",height="5").pack()
Button(adv,text="SELECT",height="5",width="5",bg="red",fg="blue",command=lambda:function4()).pack()
def perform(item):
map_dish={
"1 SAMOSA ________________________________________ 25": 11,
"2 DOSA __________________________________________ 100": 12,
"3 KACHORI _______________________________________ 20": 13,
"4 ALOO PARATHA __________________________________ 50": 14,
"5 PLAIN PARATHA _________________________________ 30": 15,
"6 PANEER PARATHA ________________________________ 60": 16,
"1 COFFEE ________________________________________ 15": 21,
"2 TEA __________________________________________ 10": 22,
"3 PEPSI _______________________________________ 35": 23,
"4 COLD COFFEE __________________________________ 50":24
}
item_nob=map_dish[item]
fset=int(item_nob)
con=sqlite3.connect("kamal.db")
sqlans=con.execute("select id,item_no,age,count from bev")
for i in sqlans:
if i[0]==fset:
nb=i[1]*i[3]+item_no
mb=i[2]*i[3]+age_no
i[3]+=1
cb=i[3]
nb=nb/i[3]
mb=mb/i[3]
con.execute("update bev set item_no=nb,age=mb,count=cb where id=fset")
con.commit()
con.close()
def select_beverage():
global sb;
sb=Toplevel(ms)
sb.geometry("900x900")
def learning(item):
global ans
row=5
column=5
map_dish={
"1 SAMOSA ________________________________________ 25": 11,
"2 DOSA __________________________________________ 100": 12,
"3 KACHORI _______________________________________ 20": 13,
"4 ALOO PARATHA __________________________________ 50": 14,
"5 PLAIN PARATHA _________________________________ 30": 15,
"6 PANEER PARATHA ________________________________ 60": 16,
"1 COFFEE ________________________________________ 15": 21,
"2 TEA __________________________________________ 10": 22,
"3 PEPSI _______________________________________ 35": 23,
"4 COLD COFFEE __________________________________ 50":24
}
age_inf=StringVar()
id_inf=username1
f2=open(id_inf,"r")
nf=f2.readline()
pf=f2.readline()
age_inf=f2.readline()
f2.close()
age_no=int(age_inf)
item_no=map_dish[item]
fans=1000000
fset=0
fstring=" "
con=sqlite3.connect("kamal.db")
sqlans=con.execute("select * from bev")
for i in sqlans:
a1=i[1]-item_no
b1=i[2]-age_no
ans1=a1*a1+b1*b1
if ans1<fans:
fans=ans1
fset=i[0]
p=1
for i in map_dish:
if map_dish[i]==fset:
fstring=i
p=0
break
if p==1:
ansv.set(fset)
else:
ansv.set(fstring)
# arr=[]
# arr.append(age_no)
# arr.append(map_dish("item"))
# matrix.append(arr)
# ans=t_fres[0]+t_fres[1]*item_no+t_fres[2]*age_no
# ansv.set(ans)
def location():
lc=Toplevel(jk)
pn=StringVar()
add=StringVar()
hno=StringVar()
Label(lc,text="Enter your location",bg="yellow",height="5",font=("calibri",17)).pack(fill=X)
Label(lc, text="pincode : ").pack()
Entry(lc, textvariable=pn).pack()
Label(lc, text="").pack()
Label(lc, text="ADDRESS").pack()
Entry(lc, textvariable=add).pack()
Label(lc, text="").pack()
Label(lc,text="HOUSE NO").pack()
Entry(lc, text="house no",textvariable=hno,show="*").pack()
Label(lc, text="").pack()
Button(lc, text="Enter",command=payment).pack()
def payment():
global ps
ps=Toplevel(jk)
ps.title("payment")
Label(ps,text="Enter Card Details", bg="yellow", width="1000", height="3", font=("Calibri", 13)).pack(fill=X)
Label(text="").pack()
global cn
global cey
global cvv
cn = StringVar()
cey = StringVar()
cvv = StringVar()
Label(ps, text="Card No : ").pack()
Entry(ps, textvariable=cn).pack()
Label(ps, text="").pack()
Label(ps, text="Card Expiry year : ").pack()
Entry(ps, textvariable=cey).pack()
Label(ps, text="").pack()
Entry(ps, text="CVV",textvariable=cvv,show="*").pack()
Label(ps, text="").pack()
Button(ps, text="Enter",command=card_verify).pack()
def card_verify():
cardn=cn.get()
cardey=cey.get()
cardvv=cvv.get()
if len(cardn)!=16 or int(cardey)< 2019:
incorrect()
else :
pay_success()
def pay_success():
global pss
pss= Toplevel(ps)
pss.title("ticket booked")
file=open(username_info,"a")
file.write("train name: Gareeb Rath \n train no : 123456 \n Seat_no : D65")
file.close()
Label(pss, text="ticket booked").pack(fill="y")
Button(pss, text="print ticket",command=print_ticket).pack()
def print_ticket():
file=open(username_info,"r")
print(file.read())
main_account_screen()
def incorrect():
global inc
inc= Toplevel(ps)
inc.title("incorrect")
Label(inc, text="incorrect details").pack(fill="y")
Button(inc, text="OK", command=delete_incorrect).pack()
def firsttime():
con=sqlite3.connect("kamal.db")
con.execute("create table bev(id int,item_no int,age int,count int)")
con.execute("insert into bev values(21,13,35,1)")
con.execute("insert into bev values(22,15,50,1)")
con.execute("insert into bev values(23,12,14,1)")
con.execute("insert into bev values(24,14,24,1)")
con.commit()
con.close()
def main_account_screen():
global ms
ms = Tk()
global beverage
global snacks
global indian
global desert
beverage=PhotoImage(file="beverage.png")
desert=PhotoImage(file="desert.png")
indian=PhotoImage(file="indian.png")
snacks=PhotoImage(file="snack.png")
image2=PhotoImage(file="zam.png")
image3=PhotoImage(file="i1.png")
Label(text="Welcome to foodie",height="5",font=("calibri",14),bg="yellow").pack(fill=X)
Label(text="Select Your Choice",height="300", font=("Calibri", 13),image=image2).pack(fill=X)
Label(text="",bg="white").pack()
Button(text="Login", height="2", width="30", command = login).pack()
Label(text="",bg="white").pack()
Button(text="Register", height="2" ,width="30", command=register).pack()
ms.configure(background="white")
ms.mainloop()
main_account_screen()