Skip to content

Commit 0ec56a1

Browse files
Add files via upload
1 parent f13624f commit 0ec56a1

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

GUI_1.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Q1:- Create a dict with name and mobile number.Define a GUI interface using tkinter and pack the label
2+
3+
'''
4+
5+
from tkinter import *
6+
d={'Rajat':9896,'Ashish':9990,'Param':9593,'Naveen':8453,'Vedant':9846,'Sahil':8595,'Ayush':9512,'Pritam':9568}
7+
root=Tk()
8+
s=Scrollbar(root)
9+
s.pack(side=RIGHT,fill=Y)
10+
l=Listbox(root,yscrollcommand=s.set)
11+
for key in d.values():
12+
l.insert(END,'Result is : '+str(key))
13+
l.pack(side=LEFT,fill=BOTH)
14+
s.config(command=l.yview())
15+
root.mainloop()
16+
17+
'''
18+
19+
##########################
20+
21+
22+
# Q2:- In the same tkinter file as created above, create a function to insert items into the dictionary.
23+
24+
25+
'''
26+
from tkinter import *
27+
d={'Rajat':9896,'Ashish':9990,'Param':9593,'Naveen':8453,'Vedant':9846,'Sahil':8595,'Ayush':9512,'Pritam':9568}
28+
def insert():
29+
k=e1.get()
30+
v=e2.get()
31+
d[k]=v
32+
l.insert(END,k)
33+
print(d)
34+
35+
root=Tk()
36+
e1=Entry(root)
37+
e1.pack()
38+
e2=Entry(root)
39+
e2.pack()
40+
b=Button(root,text="insert",command=insert)
41+
b.pack()
42+
s=Scrollbar(root)
43+
s.pack(side=RIGHT,fill=Y)
44+
l=Listbox(root,yscrollcommand=s.set)
45+
for key in d.values():
46+
l.insert(END,'Result is : '+str(key))
47+
l.pack(side=LEFT,fill=BOTH)
48+
s.config(command=l.yview())
49+
root.mainloop()
50+
51+
'''
52+
53+
54+
###################

0 commit comments

Comments
 (0)