I am a beginner to Python but not to programming in general.
I have the following code for creating 3 buttons:
Now, I want to use a function called ChangeColor to change the background color to red.
.
I have the following code for creating 3 buttons:
for i in range(1, 3):
aButton = "button" + str(i)
aButton = tkinter.Button(Gui, font=Font1, text=i, image=myPixel, width=70, height=70, compound="c", bg='white', activebackground='white')
aButton['command'] = partial(setBG, aButton)
aButton.grid(row=1, column=i)And it works. I get a three buttons.Now, I want to use a function called ChangeColor to change the background color to red.
def ChangeColor():
tkinter.button1['bg'] = 'red'I run the script but I get Error:module 'tkinter' has no attribute 'button1'How do I get a reference to any of the three buttons and change its background color?.
