You need to bind the buttons to an event and call the command differently.
Here is the code as I have altered it.
Here is the code as I have altered it.
from tkinter import * import tkinter as tk def write_slogan(event): v= event.widget['text'] print(v) root = tk.Tk() frame = tk.Frame(root) frame.pack() for k in range(0,11,1): btn = tk.Button(frame, text=str(k)) btn.bind("<Button-1>", write_slogan) btn.pack(side=tk.LEFT) root.mainloop()