How can I access a variable that contains the user input from a tkinter entry box? I want to use the input in another module. I'm having a hard time trying to do this because it's inside a function and I can't find any answers online.
I have two Python files:
gui.py
from tkinter import *
window = Tk()
entry = Entry(window)
entry.pack()
def get_input():
user_input = entry.get()
btn = Button(window, text='Get Entry Input', command=get_input)
btn.pack()
window.mainloop()
Here's my second Python file where I want to use the user_input.
main.py
import gui
show_user_input = gui.user_input
print(show_user_input)
# Obviously this method wouldn't work but I don't know what to do.
# Please help