Home > other >  Does customtkinter CTkButton hover has event option?
Does customtkinter CTkButton hover has event option?

Time:11-24

I want to perform an action when a mouse hover event occurred on customtkinter ctkbutton hover. is it yet implemented?

CodePudding user response:

Per the CTkButton source code, the on_enter method is bound to the <Enter> event. This method is predominantly focused on updating the button's appearance on hover. If you want to trigger an additional callback on hover, you'll have to add another binding to the button

def callback(event):
    # put whatever you want to do 'on hover' into this function
    print('Button hovered!')


button = CTkButton(parent, text='Button!')
# use ' ' to avoid overwriting the existing binding
button.bind('<Enter>', callback, add=' ')  
button.pack()
  • Related