How to get the specific button (that triggered the function) text in a function?
from tkinter import *
root = Tk()
def clicked():
message = Label(root,text=f"You clicked {help?} button.")
message.pack()
button0= Button(root,text="Nice day for coding ain't it?",state=ACTIVE,padx=200,pady=5,command=clicked)
button1= Button(root,text="What does evil Morty want?",state=ACTIVE,padx=200,pady=5,command=clicked)
button2= Button(root,text="Microsoft Edge==Chrome downloader",state=ACTIVE,padx=200,pady=5,command=clicked)
button3= Button(root,text="Only real programmers use Mac",state=ACTIVE,padx=200,pady=5,command=clicked)
EDIT: I think I have found an appropriate solution
from tkinter import *
root = Tk()
def clicked(text):
print(text)
button0= Button(root,text="Suit up!",state=ACTIVE,padx=200,pady=5,command=lambda: clicked(button0.cget('text')))
button1= Button(root,text="Java should hide from kotlin",state=ACTIVE,padx=200,pady=5,command=lambda: clicked(button1.cget('text')))
button2= Button(root,text="Could it be more boring?",state=ACTIVE,padx=200,pady=5,command=lambda: clicked(button2.cget('text')))
button3= Button(root,text="Bazinga",state=ACTIVE,padx=200,pady=5,command=lambda: clicked(button3.cget('text')))
button0.pack()
button1.pack()
button2.pack()
button3.pack()
root.mainloop()