I am trying to bind a function to a button, so that it is only called when you click the button. I know it is possible to use lambda, but the problem is that I have to pass variables through the function, therefore I can't use lambda.
The code below attempts to use the binding method of the button, but this is from intuition and it's not working:
from tkinter import *
root = Tk()
variable = StringVar()
entry = Entry(root, textvariable=variable, width=10)
entry.pack()
def print_something(event, n):
print(n) # I know it is supposed to be indented ;)
btn = Button(root, text='print something')
btn.bind('<Button-1>', print_something(variable))
btn.pack()
root.mainloop()