Botao com imagem que muda quando mouse em cima - samur2d2/Python GitHub Wiki

from tkinter import *
from PIL import Image, ImageTk

root = Tk()
ox = root.winfo_screenwidth()/2
oy = root.winfo_screenheight()/2
root.geometry("=300x300+%d+%d" % (ox-400,oy-345) )        

def changeOnHover(button, colorOnHover, colorOnLeave): 
    button.bind("<Enter>", func=lambda e: button.config( 
        background=colorOnHover)) 

    button.bind("<Leave>", func=lambda e: button.config( 
        background=colorOnLeave)) 

miFrame=Frame(root,bg="#686868",width=800,height=700)
miFrame.pack()  

can = Canvas(root,width=800,height=700)
can.pack()
photo=ImageTk.PhotoImage(file= r"./images/valves/valvula-def.png")
can.create_image(150,150,image=photo)

boton = Button(miFrame,image=photo,border=0)
boton.config(bg="#686868")
boton.place(x=60,y=100)

changeOnHover(boton, "white", "#686868") 
root.mainloop()
⚠️ **GitHub.com Fallback** ⚠️