-
Notifications
You must be signed in to change notification settings - Fork 345
/
dictionary.py
45 lines (29 loc) · 998 Bytes
/
dictionary.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
from tkinter import *
from PyDictionary import PyDictionary
root = Tk()
root.title('Codemy.com - Dictionary')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("570x500")
def lookup():
# Clear The text
my_text.delete(1.0, END)
# Lookup a word
dictionary = PyDictionary()
definition = dictionary.meaning(my_entry.get())
# Add definition to text box
#my_text.insert(END, defintion)
# Find keys and values in definition
for key,value in definition.items():
# put the key header in textbox
my_text.insert(END, key + '\n\n')
for values in value:
my_text.insert(END, f'- {values}\n\n')
my_labelframe = LabelFrame(root, text="Enter A Word")
my_labelframe.pack(pady=20)
my_entry = Entry(my_labelframe, font=("Helvetica", 28))
my_entry.grid(row=0, column=0, padx=10, pady=10)
my_button = Button(my_labelframe, text="Lookup", command=lookup)
my_button.grid(row=0, column=1, padx=10)
my_text = Text(root, height=20, width=65, wrap=WORD)
my_text.pack(pady=10)
root.mainloop()