Build A Word Dictionary – Python Tkinter GUI Tutorial 215

In this video we’ll build a word Dictionary with Tkinter and Python using the PyDictionary Module.

We’ll build out a simple Tkinter GUI that let’s us enter a word and click a button.

Our app will then use the PyDictionary module to look up the definition of the word, and return it to a text box in our app.

Python Code: dictionary.py
(Github Code)

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()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...