I create a button that I want to be white/red when disabled/active:
self.btn = tk.Button(cfg.win, text="Button", name = "btn", state="disabled", bg="white", activebackground="red")
where self refers to my Gui class, cfg.win is a Tkinter window with the .Tk() method.
Then a callback changes the color of the button:
self.btn.configure(state = "active")
The button turns red. When I hover on the mouse with the mouse the color is still red. However, when I leave the area of the button it turns white. The button stays active. What am I missing?
I see that a button state can be normal, active or disabled. The documentation does not say much tkinter buttons but it appears that the button is active when I hover on it with the mouse, and normal when my mouse is not on its area. So the following did the trick
self.btn.configure(state = "normal", relief="raised", bg = "red")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With