Skip to content
Advertisement

How to change multiple buttons text using only one function, tkinter python

I would like to use only one function (self.toggle) for all of my buttons in my GUI instead of doing each for every button. I have tried to change name of self.button only without numbers and then I had text changing on just one button not the one required. Is there simple way to do just one function? I’m just starting with Python. Thanks in advance.

JavaScript

Advertisement

Answer

You can pass the button widget to toggle() as below:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement