Reputation: 1245
I am developing an app with tkinter and I have the following code:
tricks = ['Always Three', 'bhu']
def trickInstructions(selectedTrick):
print(selectedTrick)
def menu():
for trick in tricks:
Button(root, text = trick, pady=1, command = lambda: trickInstructions(self.name)).pack(side=BOTTOM)
I would like to send the name of the button to the trickInstructions()
function everytime the button is clicked.
Is this possible and how?
Upvotes: 0
Views: 53
Reputation: 47173
You can pass the text using lambda
via default value of argument:
command=lambda name=trick: trickInstructions(name)
Upvotes: 1