multisearch word dictionary Tkinter gui

https://i.imgur.com/gDxulSF.png
mail@pastecode.io avatar
unknown
python
a year ago
996 B
3
Indexable
from tkinter import *


root = Tk()
root.title("Dictionary")
root.geometry("570x570")


def lookup():
    # Clear The text
    my_text.delete(1.0, END)

    # Lookup a word
    dictionary = {
        "0": "1st definition",
        "1": "2nd definition",
        "2": str(1),
        "3": "Python",
    }

    w = my_text0.get(1.0, END).split()
    print(w)

    print(dictionary.items())
    for i in w:
        if i in [*dictionary]:
            word = i.title()
            print(word)
            my_text.insert(END, word + " " + dictionary[i] + "\n")


my_labelframe = LabelFrame(root, text="Enter A Word")
my_labelframe.pack(pady=20)

my_text0 = Text(my_labelframe, height=20, width=45, wrap=WORD)
my_text0.grid(row=0, column=0, padx=10, pady=10)

my_button = Button(my_labelframe, text="Lookup", command=lookup)
my_button.grid(row=1, column=0, padx=10)

my_text = Text(root, height=40, width=65, wrap=WORD)
my_text.pack(pady=10)


root.mainloop()