I want to change the color of button as soon as my mouse is above it, hovering over the button, I know but I am facing error I am using the bind functions of tkinter python to create hover effect, I searched stackoverflow and came accross the successful implementation of and and I tried to implement that to my code but so far I am unsuccessful in doing so. I looked over this code: Tkinter Hovering over Button -> Color change
def clicked():
res = "Welcome to " + txt.get()
lbl.configure(text= res)
def on_enter(e):
btn['background'] = '#FFD51B'
def on_leave(e):
btn['background'] = '#0A22B1'
root = Tk()
root.geometry("1366x768")
root.configure(bg="blue")
#root.attributes('-fullscreen', True)
root.state('zoomed')
abc=Frame(root,bg="blue",height=200,width=100)
abc.pack(side='top')
abc1=Frame(root,bg="blue",height=400,width=510)
abc1.pack(side='top')
a = Label(abc1 ,text = "First Name:",fg="white",
font="Courier 20 bold",bg="blue").place(x=1,y=1)
b = Label(abc1 ,text = "Last Name:",fg="white",
font="Courier 20 bold",bg="blue").place(x=1,y=42)
c = Label(abc1 ,text = "Email Id:",fg="white",
font="Courier 20 bold",bg="blue").place(x=1,y=83)
d = Label(abc1 ,text = "Contact Number:",fg="white",
font="Courier 20 bold",bg="blue").place(x=1,y=124)
a1 = Entry(abc1,width=25).place(x=300,y=9)
b1 = Entry(abc1,width=25).place(x=300,y=51)
c1 = Entry(abc1,width=25).place(x=300,y=92)
d1 = Entry(abc1,width=25).place(x=300,y=134)
btn = Button(abc1 ,text="Submit",height=2,width=20,activebackground="#FFD51B",
bg="#0A22B1",fg="white",font="Courier 11 bold").place(x=150,y=176)
btn.bind("<Enter>", on_enter)
btn.bind("<Leave>", on_leave)
root.mainloop()
The error is:- btn.bind("", on_enter) AttributeError: 'NoneType' object has no attribute 'bind' I don't know what I am doing wrong, according to my knowledge the code is logically correct