How to Change Background Color of a Tkinter Button When Clicked in Python
In this tutorial, we are going to see how to change the background color of a Tkinter Button when clicked in Python. You are able to change the background color of a button, when the button was clicked, by using the activebackground property of the button.
Example: Change Background Color of a Tkinter Button When Clicked
In the following example, we will change the background color of the button to yellow when it is pressed.
from tkinter import *
gui = Tk()
gui.geometry('200x100')
btn = Button(gui, text = 'Click here!', activebackground='yellow')
btn.pack()
gui.mainloop()
Output:





