forked from Manasvi070902/hacktoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddress.py
65 lines (60 loc) · 2.17 KB
/
address.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
from tkinter import *
root = Tk()
root.geometry('400x400')
root.config(bg = 'SlateGray3')
root.resizable(0,0)
root.title('DataFlair-AddressBook')
contactlist = [
['Parv Maheswari', '0176738493'],
['David Sharma', '2684430000'],
['Mandish Kabra', '4338354432'],
['Prisha Modi','6834552341'],
['Rahul kaushik', '1234852689'],
['Johena Shaa' , '2119876543'],
]
Name = StringVar()
Number = StringVar()
frame = Frame(root)
frame.pack(side = RIGHT)
scroll = Scrollbar(frame, orient=VERTICAL)
select = Listbox(frame, yscrollcommand=scroll.set, height=12)
scroll.config (command=select.yview)
scroll.pack(side=RIGHT, fill=Y)
select.pack(side=LEFT, fill=BOTH, expand=1)
def Selected():
return int(select.curselection()[0])
def AddContact():
contactlist.append([Name.get(), Number.get()])
Select_set()
def EDIT():
contactlist[Selected()] = [Name.get(), Number.get()]
Select_set()
def DELETE():
del contactlist[Selected()]
Select_set()
def VIEW():
NAME, PHONE = contactlist[Selected()]
Name.set(NAME)
Number.set(PHONE)
def EXIT():
root.destroy()
def RESET():
Name.set('')
Number.set('')
def Select_set() :
contactlist.sort()
select.delete(0,END)
for name,phone in contactlist :
select.insert (END, name)
Select_set()
Label(root, text = 'NAME', font='arial 12 bold', bg = 'SlateGray3').place(x= 30, y=20)
Entry(root, textvariable = Name).place(x= 100, y=20)
Label(root, text = 'PHONE NO.', font='arial 12 bold',bg = 'SlateGray3').place(x= 30, y=70)
Entry(root, textvariable = Number).place(x= 130, y=70)
Button(root,text=" ADD", font='arial 12 bold',bg='SlateGray4', command = AddContact).place(x= 50, y=110)
Button(root,text="EDIT", font='arial 12 bold',bg='SlateGray4',command = EDIT).place(x= 50, y=260)
Button(root,text="DELETE", font='arial 12 bold',bg='SlateGray4',command = DELETE).place(x= 50, y=210)
Button(root,text="VIEW", font='arial 12 bold',bg='SlateGray4', command = VIEW).place(x= 50, y=160)
Button(root,text="EXIT", font='arial 12 bold',bg='tomato', command = EXIT).place(x= 300, y=320)
Button(root,text="RESET", font='arial 12 bold',bg='SlateGray4', command = RESET).place(x= 50, y=310)
root.mainloop()