Skip to content

Commit 1148844

Browse files
committed
GUI updated and meaning fetch and display setup
1 parent 6fad99b commit 1148844

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

Dictionary-GUI/dictionary.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
11
from tkinter import *
2+
from tkinter import messagebox
3+
from PyDictionary import PyDictionary
24

5+
# Creating Tkinter Scaffold
36
root = Tk()
47
root.title("Dictionary")
58
root.geometry("500x400")
69

10+
# Initialize dictionary objecy
11+
dictionary = PyDictionary()
712

813
def getMeaning():
9-
frame1 = Frame(root)
10-
Label(frame1, text="Meaning:- ", font=("Helvetica 10 bold")).pack(side=LEFT)
11-
meaning = Label(frame1, text="", font=("Helvetica 10"))
12-
meaning.pack()
13-
frame1.pack(pady=10)
14-
14+
response=dictionary.meaning(word.get())
15+
if(response):
16+
if('Noun' in response):
17+
meaning=response['Noun'][0]
18+
elif('Verb' in response):
19+
meaning=response['Verb'][0]
20+
elif('Adjective' in response):
21+
meaning=response['Adjective'][0]
22+
else:
23+
meaning="Invalid word"
24+
else:
25+
messagebox.showinfo("Error","Please add a Noun, Pronoun, verb or a valid word.")
26+
# Show meaning in frame
27+
meaning_label.config(text=meaning)
28+
1529

1630
# Heading Label
17-
heading_label = Label(root, text = "DICTIONARY", font=("Helvetica 21 bold"))
31+
heading_label = Label(root, text = "DICTIONARY", font=("Helvetica 35 bold"),foreground='Blue')
1832
heading_label.config(anchor=CENTER)
1933
heading_label.pack(pady=10)
2034

35+
# Frame for search box and search button
2136
frame = Frame(root)
2237
Label(frame, text="Enter Word", font=("Helvetica 15 bold")).pack(side=LEFT)
2338
word = Entry(frame, font=("Helvetica 15 bold"))
2439
word.pack(padx=10)
2540
frame.pack()
2641

27-
search_button=Button(root, text="Search Word", font=("Helvetica 15 bold"), command=getMeaning)
42+
search_button=Button(root, text="Search Word",font=("Helvetica 15 bold"),relief=RIDGE,borderwidth=3,cursor="hand2",foreground='Green', command=getMeaning)
2843
search_button.config(anchor=CENTER)
2944
search_button.pack(pady=10)
3045

46+
# Frame to display meaning
47+
frame1 = Frame(root)
48+
Label(frame1, text="Meaning : ", font=("Helvetica 15 bold")).pack(side=LEFT)
49+
meaning_label = Label(frame1, text="", font=("Helvetica 12"))
50+
meaning_label.pack(pady=5)
51+
frame1.pack(pady=10)
3152

3253
# Execute Tkinter
3354
root.mainloop()

0 commit comments

Comments
 (0)