tkinter - get button name? tkinter - get button name? tkinter tkinter

tkinter - get button name?


Bryan's answer may not exactly address the question, in particular, his solution works only if the button's text never changes after it has been created.

button.config('text')[-1]

returns the actual button's text.


You are almost there. You simply need to pass the name via lambda or functools.partial:

newbuttonname = username newbuttonname = Tkinter.Button(win, text = newbuttonname,     command = lambda name=username:click_one(name))

You can use this same technique to pass in the actual wodget, or any other data.


While you label the button, it should be in quotes:

newbuttonname = tk.Button(win, text="NewButtonName")