-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBookStore_GUI.py
91 lines (85 loc) · 2.05 KB
/
BookStore_GUI.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
import BookStore_Database as n
def insert():
w=[e1.get(),e2.get(),e3.get(),e4.get()]
l.insert(END,w)
n.insertdb(e1.get(),e2.get(),e3.get(),e4.get())
e1.delete(0,END)
e2.delete(0,END)
e3.delete(0,END)
e4.delete(0,END)
def delete():
s=l.curselection()
a=l.index(s)
b=l.get(a)
c=b[0]
l.delete(s)
print(a)
print(b)
print(c)
n.deletedb(c)
e1.delete(0,END)
e2.delete(0,END)
e3.delete(0,END)
e4.delete(0,END)
def update():
s=l.curselection()
n.updatedb(e1.get(),e2.get(),e3.get(),e4.get())
l.delete(s)
w=[e1.get(),e2.get(),e3.get(),e4.get()]
l.insert(s,w)
e1.delete(0,END)
e2.delete(0,END)
e3.delete(0,END)
e4.delete(0,END)
def view():
l.delete(0,END)
x=n.viewdb()
for item in x:
l.insert(END,item)
def search():
x=n.searchdb(e1.get(),e2.get(),e3.get(),e4.get())
e1.delete(0,END)
e2.delete(0,END)
e3.delete(0,END)
e4.delete(0,END)
e1.insert(END,x[1])
e2.insert(END,x[2])
e3.insert(END,x[3])
e4.insert(END,x[4])
from tkinter import *
windows=Tk()
Frame1 = Frame(windows)
Frame1.pack( side = TOP )
l1=Label(Frame1,text=' Title')
l1.pack(side=LEFT)
e1=Entry(Frame1)
e1.pack(side=LEFT)
l2=Label(Frame1,text='Author')
l2.pack(side=LEFT)
e2=Entry(Frame1)
e2.pack(side=LEFT)
Frame2 = Frame(windows)
Frame2.pack( side = TOP )
l3=Label(Frame2,text='Year')
l3.pack(side=LEFT)
e3=Entry(Frame2)
e3.pack(side=LEFT)
l4=Label(Frame2,text='ISBN ')
l4.pack(side=LEFT)
e4=Entry(Frame2)
e4.pack(side=LEFT)
l= Listbox(windows,width=30)
l.pack( side = LEFT, fill = BOTH )
Frame3 = Frame(windows)
Frame3.pack( side = RIGHT )
b1=Button(Frame3,text='View All',command=view,width=15)
b1.pack(side=TOP)
b2=Button(Frame3,text='Search Entry',command=search,width=15)
b2.pack(side=TOP)
b3=Button(Frame3,text='Add Entry',command=insert,width=15)
b3.pack(side=TOP)
b4=Button(Frame3,text='Update Selected',command=update,width=15)
b4.pack(side=TOP)
b5=Button(Frame3,text='Delete Selected',command=delete,width=15)
b5.pack(side=TOP)
windows.mainloop()