I am building a Tkinter App. You can enter a query and python will look for that key in a .json file. I want to get the value of the textEntry box and store it as the query variable, but instead I get null as the variable and I cannot enter a new query and search for something else.
from tkinter import *
import json
def searchDict():
with open("database.json", "r") as read_file:
query = textEntry.get()
data = json.load(read_file)
print(data.get(query))
root=Tk()
root.geometry('800x600')
root.title("Dictionary of Information yes")
introduction = Label(root, text="This is a Dictionary of People and info about them! please dont arrest me")
entertext = Label(root, text="Enter the name here: ")
textEntry = Entry(root)
query = textEntry.get()
buttonEntry = Button(root, text="Search", command=searchDict())
resultBox = Text(root, width=250, height=100)
introduction.pack()
entertext.pack()
textEntry.pack()
buttonEntry.pack()
resultBox.pack()
root.mainloop()