I have a function that has a tkinter window defined and run inside of it. There is a button in that window, and I need the button to execute a return statement and return a value for the function.
The way to do things other than run argumentless functions from button callbacks seems to be lambda, but I can't figure out a way to do this with lambda, as any value returned from the lambda registers as the return value for the lambda.
The gist of my code is like this:
from tkinter import *
def function():
root = Tk()
entry = Entry(root)
entry.pack()
button = Button(root, text = "I'm a button", command = return entry.get()) #Does not work, you can't do this in a callback
button.pack()
root.mainloop()
What I'm trying to figure out is how to rewrite that return statement so that it is valid for the command argument.
returnis useless withButtonbecause there is nobody who can receive returned value.