Define a frame in the root window and the label requires the user to enter a word. Pass the parameters as before and place the widget on the left side. Define an input widget to give the user space to type words. Add it to the frame widget and define the font style as well. Arrange and add some padding to both widgets.
Label(root, text="Word Dictionary Using Python", font=("Arial 36 bold"), fg="Purple").pack(pady=10) frame = Frame(root) Label(frame, text="Type Word:", font=("Arial 28 bold")).pack(side=LEFT) word = Entry(frame, font=("Arial 23 bold")) word.pack() frame.pack(pady=10)
Specify a frame containing the meaning label and another label that will show the meaning of the word by clicking the Submit button . Place it inside the canvas created above and set the font style accordingly. Use the wraplength property to collapse a long sentence into several parts. Its size is set in screen units.
Arrange and add some padding to labels and frames.
frame1 = Frame(root) Label(frame1, text="Meaning: ", font=("Arial 18 bold")).pack(side=LEFT) meaning = Label(frame1, text="", font=("Arial 18"),wraplength=1000) meaning.pack() frame1.pack(pady=15)
Repeat the above steps for synonyms & antonyms frames and labels.
frame2 = Frame(root) Label(frame2, text="Synonym: ", font=("Arial 18 bold")).pack(side=LEFT) synonym = Label(frame2, text="", font=("Arial 18"), wraplength=1000) synonym.pack() frame2.pack(pady=15) frame3 = Frame(root) Label(frame3, text="Antonym: ", font=("Arial 18 bold")).pack(side=LEFT) antonym = Label(frame3, text="", font=("Arial 18"), wraplength=1000) antonym.pack(side=LEFT) frame3.pack(pady=20)
Define the Submit button . Set the parent window in which you want to place the button and the content it should display, the font style, the function it runs when clicked. The mainloop() function tells Python to loop through the Tkinter event and listen for events until you close the window.
Button(root, text="Submit", font=("Arial 18 bold"), command=dict).pack() root.mainloop()
Put all the code together and your dictionary application is ready to run.
Result:
When running the above program, it shows the application window. When entering a word, it shows the meaning of the word and a list of synonyms and antonyms.
Above is how to create a dictionary app in Python . As you can see, it's pretty simple, isn't it?