You can simply do:
my_text = my_button['text']
Tkinter allows you to access any option of a widget this way (height, width, text, etc.)
If you need this as a method call, you can use .cget:
my_text = my_button.cget('text')
Note that this method is available on all standard Tkinter widgets.
Answer from user2555451 on Stack OverflowTutorialsPoint
tutorialspoint.com βΊ get-the-text-of-a-button-widget-in-tkinter
Get the text of a button widget in Tkinter
April 21, 2021 - #Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win= Tk() #Set the geometry of tkinter frame win.geometry("750x250") #Create a button button= ttk.Button(win, text="My Button") button.pack() #Get the text of Button mytext= ...
Python tkinter how to get text from button I clicked on - Stack Overflow
I have code like this (just part of a code). I need when someone click on the button that is in list named buttonList then it gets buttons text. This is code how I make render of those buttons. Its More on stackoverflow.com
python - Print the clicked button's text tkinter - Stack Overflow
Additionally you can use print(b[d].cget('text')) if using the list is preferred . Since the button objects are appended to a list you can use that to get the text from them. More on stackoverflow.com
python - How to get a button text in a function - tkinter? - Stack Overflow
In the code below, this is done by separating the Button creation from the configuring its command option, which is now done after they all exist. from tkinter import * root = Tk() def clicked(btn): btn_text = btn.cget('text') message = Label(root, text=f'You clicked button "{btn_text}".') ... More on stackoverflow.com
Python 3, Tkinter, How to update button text - Stack Overflow
How can I make it so that the text on the button is updated? My best idea so far has been to delete the buttons then print them again, but that only deletes one button. Here's what I have so far: from tkinter import * BoardValue = ["-","-","-","-","-","-","-","-","-"] window = Tk() ... More on stackoverflow.com
Videos
05:45
Python Tkinter: How to Capture Text Box Entries on Submit Button ...
11:35
Python Tutorial - Tkinter Entry and Buttons - YouTube
06:15
Tkinter Tutorial For Beginners - Buttons in Tkinter - YouTube
14:37
Tkinter Text Widget - Tkinter tutorial for beginners #6 - YouTube
14:31
Entry Boxes for Text - Intro To Tkinter 2 - YouTube
34:34
Tkinter #3 - Ways to Get User Input - YouTube
Reddit
reddit.com βΊ r/tkinter βΊ checking the name of a button that is clicked
r/Tkinter on Reddit: checking the name of a button that is clicked
September 21, 2021 -
I have multiple buttons being made and I want to call to a function using the button's name as one of the variables. How would I get the name of the button into the function?
Top answer 1 of 2
2
The simplest solution is to create the button without a command, and then configure the command in a separate step. button = tk.Button(root, text="Whatever") button.configure(command=lambda b=button: some_command(b))
2 of 2
1
You could use a lambda expression and pass the name as an argument: tk.Button(master, text='btn', command=lambda: function('BTN name')) If possible you might want to call a different function for each button alternatively.
Python Course
python-course.eu βΊ tkinter βΊ buttons-in-tkinter.php
3. Buttons in Tkinter | Tkinter | python-course.eu
The following script shows an example, where a label is dynamically incremented by 1 until a stop button is pressed: import tkinter as tk counter = 0 def counter_label(label): counter = 0 def count(): global counter counter += 1 label.config(text=str(counter)) label.after(1000, count) count() root = tk.Tk() root.title("Counting Seconds") label = tk.Label(root, fg="dark green") label.pack() counter_label(label) button = tk.Button(root, text='Stop', width=25, command=root.destroy) button.pack() root.mainloop()
Universidad de Granada
ccia.ugr.es βΊ mgsilvente βΊ tkinterbook βΊ button.htm
The tkinter Button Widget
The text can contain newlines. If the bitmap or image options are used, this option is ignored (unless the compound option is used). (text/Text) ... Associates a tkinter variable (usually a StringVar) to the button. If the variable is changed, the button text is updated.
Python Examples
pythonexamples.org βΊ python-tkinter-change-button-text-dynamically
Python Tkinter - Change Button Text Dynamically
You can change the text property of Tkinter button using the reference to the button and 'text' option as index. The pseudo code would be button['text'] = 'new value'.
GeeksforGeeks
geeksforgeeks.org βΊ how-to-check-which-button-was-clicked-in-tkinter
How to check which Button was clicked in Tkinter ? - GeeksforGeeks
July 29, 2024 - In this example, if the text 'It is an apple' is printed on the screen, we get to know 'Apple' button is pressed, else when 'It is a banana' is printed on the screen, we get to know 'Banana' button is pressed. ... # Import the library tkinter from tkinter import * # Create a GUI app app = Tk() # Create a function with one parameter to indicate which button was clicked def which_button(button_text): # Printing the text when a button is clicked print(f"Button clicked: {button_text}") # Creating and displaying of button b1 b1 = Button(app, text="Apple", command=lambda: which_button("Apple")) b1.grid(padx=10, pady=10) # Creating and displaying of button b2 b2 = Button(app, text="Banana", command=lambda: which_button("Banana")) b2.grid(padx=10, pady=10) # Make the infinite loop for displaying the app app.mainloop()
Home and Learn
homeandlearn.uk βΊ tkinter-button-widget.html
Python Tkinter button widget
Contents page and menu for the free python course pages.
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. Here are the common configurations of the button widget: button = ttk.Button( master, text=label, command=fn )Code language: Python (python)
Tutorialspoint
tutorialspoint.com βΊ python βΊ tk_button.htm
Tkinter Button
These buttons can display text or images that convey the purpose of the buttons. You can attach a function or a method to a button which is called automatically when you click the button. Here is the simple syntax to create this widget β ... options β Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas. Following are commonly used methods for this widget β ... 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()
Top answer 1 of 7
38
To sum up this thread: button.config and button.configure both work fine!
button.config(text="hello")
or
button.configure(text="hello")
2 of 7
15
The Button widget, just like your Label, also has a textvariable= option. You can use StringVar.set() to update the Button. Minimal example:
import tkinter as tk
root = tk.Tk()
def update_btn_text():
btn_text.set("b")
btn_text = tk.StringVar()
btn = tk.Button(root, textvariable=btn_text, command=update_btn_text)
btn_text.set("a")
btn.pack()
root.mainloop()
CopyProgramming
copyprogramming.com βΊ howto βΊ read-text-from-button-tkinter-duplicate
How to Get Button Text in Tkinter Python - Button text in tkinter python
January 25, 2026 - ... Getting the text of a button in Tkinter is straightforward using the cget('text') method or direct dictionary access like button['text']. This works for both classic Tkinter buttons and themed ttk buttons, allowing you to read dynamic labels in event handlers or for validation.
