I am trying to make a script that will change the background and foreground color of a widget after freezing.
from Tkinter import * root=Tk() Hover1=Button(root,text="Red color", bg="white") Hover1.pack() Hover2=Button(root,text="Yellow color", bg="white") Hover2.pack() Hover1.bind("<Enter>",Hover1.configure(bg="red")) Hover1.bind("<Leave>",Hover1.configure(bg="white")) Hover2.bind("<Enter>",Hover2.configure(bg="yellow")) Hover2.bind("<Leave>",Hover2.configure(bg="white")) root.mainloop()
but when I press any button nothing happens, they remain white. I know that I can use a function, but for each widget there will be two functions (1 for, 1 for). I would like to create one function that will repaint this widget that I am hanging on and explain why this script does not do what I want it to do.
I hope I have described my problem well. Thanks for every reply.
PS: I would like to avoid classes.
mountDoom
source share