Q:

giving arguements to a function without calling it in tkinter

I want to make a function that has a parameter and I want to assign it to a button of tkinter and give it the argument but when I write () to the function it automatically calls it without assigning it.
I tried this code.
def printer(a):
    print(a)
import tkinter
x=tkinter.Tk()
frame=tkinter.Frame(x)
button=tkinter.Button(frame,text="print",command=printer)
button.pack()
frame.pack()
x.mainloop()

A:

You can use functools.partial to supply arguments beforehand:
In [1]: from functools import partial

In [2]: def printer(event, text): 
   ...:     print(text) 
   ...:

In [3]: newfn = partial(printer, text="This is the text to print.")

In [4]: newfn(None)
This is the text to print.

Note that Tkenter event handlers are called with a single argument which is an Event instance. See events and bindings.

