Python tkinter how to use what is written in an input widget

How do I use what is entered in a Tkinter input widget in the rest of the program?
I have this for the entry:

n = StringVar()
Entry(search1, textvariable=n).pack()
label = n.get()

with open('data.txt') as json_file:
    data = json.load(json_file)
    for p in data:
        recipe = p('recipe')
        recipeNames= recipe('label')
        if recipeNames == label:
            recipeName = label
            ingredients = ()
            for j in recipe('ingredients'):
Button(search1, text="Enter", command=partial(addrecipe, recipeName, calendarID, ingredients, service)).pack()

When I try to use the variable, it has nothing and returns with an error. How do I assign a variable to what is in the input widget?