Skip to content
Related Articles

Related Articles

Word Dictionary using Tkinter
  • Last Updated : 24 Jan, 2021

Prerequisite:

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python.

In this article, we will learn how to make Word Dictionary in Tkinter. 

PyDictionary is a dictionary (as in the English language dictionary) module for Python2 and Python3. PyDictionary provides the following services for a word:

  • meanings
  • translations
  • synonym
  • antonym

Approach

  • Import module
  • Create Normal Tkinter window
  • Add Some Button, Labels & Frames

Syntax:



# Button

Button(Object Name, text=”Enter Text”,**attr)

# Label

Label(Object Name, text=”Enter Text”, command=”Enter Command” , **attr)

# Frame

Frame(Object Name, **attr)

  • Make a function named as dict. This function will give the meaning, synonym & antonym of given word.
  • Execute code

Program:

Python3




# Import Required Library
from tkinter import *
from PyDictionary import PyDictionary
  
# Create Objects
dictionary = PyDictionary()
root = Tk()
  
# Set geometry
root.geometry("400x400")
  
  
def dict():
    meaning.config(text=dictionary.meaning(word.get())['Noun'][0])
    synonym.config(text=dictionary.synonym(word.get()))
    antonym.config(text=dictionary.antonym(word.get()))
  
  
# Add Labels, Button and Frames
Label(root, text="Dictionary", font=(
    "Helvetica 20 bold"), fg="Green").pack(pady=10)
  
# Frame 1
frame = Frame(root)
Label(frame, text="Type Word", font=("Helvetica 15 bold")).pack(side=LEFT)
word = Entry(frame, font=("Helvetica 15 bold"))
word.pack()
frame.pack(pady=10)
  
# Frame 2
frame1 = Frame(root)
Label(frame1, text="Meaning:- ", font=("Helvetica 10 bold")).pack(side=LEFT)
meaning = Label(frame1, text="", font=("Helvetica 10"))
meaning.pack()
frame1.pack(pady=10)
  
# Frame 3
frame2 = Frame(root)
Label(frame2, text="Synonym:- ", font=("Helvetica 10 bold")).pack(side=LEFT)
synonym = Label(frame2, text="", font=("Helvetica 10"))
synonym.pack()
frame2.pack(pady=10)
  
# Frame 4
frame3 = Frame(root)
Label(frame3, text="Antonym:- ", font=("Helvetica 10 bold")).pack(side=LEFT)
antonym = Label(frame3, text="", font=("Helvetica 10"))
antonym.pack(side=LEFT)
frame3.pack(pady=10)
  
Button(root, text="Submit", font=("Helvetica 15 bold"), command=dict).pack()
  
# Execute Tkinter
root.mainloop()

Output:


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :