This can be done using a lambda, like so:

button = Tk.Button(master=frame, text='press', command= lambda: action(someNumber))

This is a simple way to bind the argument without an explicit wrapper method or modifying the original action.

Answer from Voo on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-pass-arguments-to-tkinter-button-command
How to Pass Arguments to Tkinter Button Command? - GeeksforGeeks
July 23, 2025 - # importing tkinter import tkinter as tk # defining function def func(args): print(args) # create root window root = tk.Tk() # root window title and dimension root.title("Welcome to GeekForGeeks") root.geometry("380x400") # creating button btn = tk.Button(root, text="Press", command=lambda: func("See this worked!")) btn.pack() # running the main loop root.mainloop()
Discussions

How to use a Tkinter button (call a function) that has an argument?
You can do this with lambda or partial. But not in this case, because you've misdignosed the problem. You need to make the entry an instance variable, then you will be able to access it from the method without passing it. class newTopLevel(object): def __init__(self, root): self.newWindow = Toplevel(root) self.entry_1 = tk.Entry(self.newWindow) # <==change here self.entry_1.grid(row=0, column=1) self.newWindow.btn = tk.Button(self.newWindow,text='Enter',command=self.fun) self.newWindow.btn.grid(row=0,column=2) def fun(self): get_value=self.entry_1.get() More on reddit.com
๐ŸŒ r/learnpython
11
1
November 20, 2020
How to call same function with different argument given from list in tkinter button command option
from tkinter import * def fun(nm): msg= 'hello {}'.format(nm) print(msg) master=Tk(className="testing") list=[1,2,3,4] for x in list: para=x Button(master, text=x, command=lambda:fun(x)).pack(side='left') master.mainloop() getting output hello 4 every time More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
November 8, 2019
Buttons with same parameters
Sorry, there is no params= argument for tkinter buttons. All you have is the command= argument. It is possible to pass arguments to the function specified in the command= argument, as explained here . There are complications than can arise depending on the command arguments you pass, so maybe you can give a small example of what you want to pass, More on reddit.com
๐ŸŒ r/learnpython
4
1
March 31, 2022
Tkinter button command using lambda to call a class method - how???
command=self.open_notebook will work, and is a better than using lambda in my opinion. You also need to move most of the code under def __init__ rather than where it is. class MainWidget: def __init__(self): root = Tk() root.geometry("400x400") search_frame = Frame(root) search_frame.pack() self.search_function = SearchFunction(search_frame) open_notebook_button = Button(root, text="Open", command=self.open_notebook) open_notebook_button.pack() root.mainloop() def open_notebook(self): self.search_function.get_emp_id() # and more stuff to add later More on reddit.com
๐ŸŒ r/Tkinter
4
4
September 11, 2022
๐ŸŒ
Python Tutorial
pythontutorial.net โ€บ home โ€บ tkinter tutorial โ€บ tkinter command binding
Tkinter Command Binding - Python Tutorial
April 3, 2025 - When you click a button, the lambda expression associated with the buttonโ€™s command will execute. Itโ€™ll be called the select() function with a string argument.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to use a tkinter button (call a function) that has an argument?
r/learnpython on Reddit: How to use a Tkinter button (call a function) that has an argument?
November 20, 2020 -

Hello everyone,

I have a Tkinter window that is defined in a class, and I have a function that gets a value from the Tkinter window.

I.E.

class newTopLevel(object):
    def __init__(self, root):
        self.newWindow = Toplevel(root)
        entry_1 = tk.Entry(self.newWindow).grid(row=0, column=1)
        self.newWindow.btn = tk.Button(self.newWindow,text='Enter',command=self.fun)
        self.newWindow.btn.grid(row=0,column=2)
    def fun(self):
        get_value=entry_1.get()

The issue here is entry_1 is not defined in my function. I normally don't have my Tkinter within a class, thus its a global and its properties (such as buttons and entry grids) are globals and they don't have to be defined. However in this case, now it does need to defined. I tried this:

def fun(self,entry_1):
        get_value=entry_1.get()

However, then I cannot use the button command to call it.

self.newWindow.btn = tk.Button(self.newWindow,text='Enter',command=self.fun(entry_1))

If I don't include the argument entry_1, then I'll get an error that fun has an argument and I haven't given any when using the button. I don't quite know how to use a Tkinter button that has arguments. Any help would be greatly appreciated!

๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ tk_button.htm
Tkinter Button
from tkinter import * from tkinter import messagebox top = Tk() top.geometry("100x100") def helloCallBack(): msg=messagebox.showinfo( "Hello Python", "Hello World") B = Button(top, text ="Hello", command = helloCallBack) B.place(x=50,y=50) top.mainloop() When the above code is executed, it produces the following result โˆ’ ยท
๐ŸŒ
DaniWeb
daniweb.com โ€บ programming โ€บ software-development โ€บ threads โ€บ 166751 โ€บ tkinter-button-widget-passing-parameter-to-function
python - tkinter button widget - passing parameter ... [SOLVED] | DaniWeb
January 7, 2009 - A Tkinter buttonโ€™s command must be a callable you pass by reference. Writing command=getCond(item) calls the function immediately; instead, build a callable that remembers the argument.
๐ŸŒ
AIMosta
aimosta.com โ€บ Blogt โ€บ blogt-15.html
The Button Command with Parameters
Now, to define the property command of the button (the function that will be called), we will use lambda that will be equal to the call of the changeColor function with our button as a parameter.
Find elsewhere
๐ŸŒ
Python Forum
python-forum.io โ€บ thread-35506.html
Button 'command' Argument Confusion
November 10, 2021 - I am confused by the 'command' argument for buttons. I have the following button defined: submitButton=tk.Button(top,text='Submit',command=submitData(top)).grid(row=rw,column=2,pady=5,sticky=tk.W)The command (submitData) is being executed immediately...
๐ŸŒ
Python Programming
pythonprogramming.net โ€บ passing-functions-parameters-tkinter-using-lambda
Passing functions with Parameters in Tkinter using Lambda
Next, here's our new StartPage, with an added button: class StartPage(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self,parent) label = tk.Label(self, text="Start Page", font=LARGE_FONT) label.pack(pady=10,padx=10) button = tk.Button(self, text="Visit Page 1", command=lambda: qf("Check me out, I'm passing vars!")) button.pack()
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ passing-arguments-to-a-tkinter-button-command
Passing arguments to a Tkinter button command
August 5, 2021 - # Import the required library from tkinter import * from tkinter import ttk from tkinter import messagebox # Create an instance of tkinter frame win=Tk() # Set the geometry win.geometry("700x250") # Define a function to update the entry widget def update_name(name): entry.insert(END, ""+str(name)) # Create an entry widget entry=Entry(win, width=35, font=('Calibri 15')) entry.pack() b=ttk.Button(win, text="Insert", command=lambda:update_name("Tutorialspoint")) b.pack(pady=30) win.mainloop() Running the above code will display a window with an Entry widget and a button to insert text in it.
๐ŸŒ
Eddie Jackson
eddiejackson.net โ€บ wp
Python โ€“ Pass Argument to a Button Command in Tkinter โ€“ Lab Core | The Lab of MrNetTek
import tkinter as tk import webbrowser # FUNCTION def openURL(x): new = 2 webbrowser.open(x,new=new) # FORM SETUP root = tk.Tk() root.geometry("350x300")# X Y root.resizable(0,0) root.title("") # button button = tk.Button(root, text='Google Search', width=25, command= lambda: openURL("http://google.com")) button.pack() root.mainloop()
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python tkinter โ€บ how to pass arguments to tkinter button command
How to Pass Arguments to Tkinter Button Command | Delft Stack
February 2, 2024 - button = tk.Button(app, text="Press Me", command=action(args)) We will introduce two ways to pass the arguments to the command function. As demonstrated in Python Tkinter tutorial, you have the option to use the partial object from the functools module.
๐ŸŒ
Python Tutorial
pythontutorial.net โ€บ home โ€บ tkinter tutorial โ€บ tkinter button
Tkinter Button - Python Tutorial
April 3, 2025 - This is called the command binding in Tkinter. ... The master is the parent widget on which you place the button. The **kw is one or more keyword arguments you use to change the appearance and behaviors of the button.
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
How to call same function with different argument given from list in tkinter button command option - Python Help - Discussions on Python.org
November 8, 2019 - from tkinter import * def fun(nm): msg= 'hello {}'.format(nm) print(msg) master=Tk(className="testing") list=[1,2,3,4] for x in list: para=x Button(master, text=x, command=lambda:fun(x)).pack(side='left') master.mainloop() getting output hello 4 every time
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-can-i-pass-arguments-to-tkinter-button-s-callback-command
How can I pass arguments to Tkinter button's callback command?
We will pass the label as the argument in the button command by using lambda function. #Import necessary Library from tkinter import * from tkinter import ttk #Create an instance of tkinter window win= Tk() #Set the geometry of tkinter window win.geometry("750x250") #Define the function to ...
๐ŸŒ
CodeSpeedy
codespeedy.com โ€บ home โ€บ how to pass arguments to a button command in tkinter
How to pass arguments to a Button command in Tkinter - CodeSpeedy
January 22, 2022 - #import libraries from tkinter import * #creating a function to call by button def display(args): print(args) #Creating tkinter object tkobj = Tk() #setting dimensions tkobj.title("Codespeedy") tkobj.geometry("400x400") #Creating button bt = Button(tkobj,text="Click me",command=lambda: display("Welcome to codespeedy!!"),pady=100) bt.pack() #looping tkobj.mainloop()
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ buttons with same parameters
r/learnpython on Reddit: Buttons with same parameters
March 31, 2022 -

Happened to just stumble across this sub while looking for an answer that I can not find. Hopefully I can get an answer.

I've been working with python on and off for a while now. Trying to make a program with Tkinter. I have multiple buttons that I'm trying to place but I want all the parameters to be the same.

The code looks like this (don't post often so not sure how to do the code thing)

params= { 'font'= ('Courier', 10), 'width'= 15, 'height'= 5, }

tk.button(text='new button', command, params)

I know usually when passing multiple parameters I can just do params = params and all is good. Its not working with the buttons. Anything I look up tells me how to do multiple commands or multiple arguments in the command. Am I on the right track or am I missing something?

๐ŸŒ
Python GUIs
pythonguis.com โ€บ tutorials โ€บ getting started with tkinter โ€บ create buttons in tkinter
Button Widgets in Tkinter
July 13, 2022 - We create the turn_off, vol_up, and vol_down buttons in a similar fashion and pack them with pack(). Only one of these buttons, turn_off, does something because we used the keyword command argument to make the button call root.destroy(), which closes the root window immediately: