Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

change the color of the button on hovering tkinter

import tkinter as tk

def on_enter(e):
    myButton['background'] = 'green'

def on_leave(e):
    myButton['background'] = 'SystemButtonFace'

root = tk.Tk()
myButton = tk.Button(root,text="Click Me")
myButton.grid()


myButton.bind("<Enter>", on_enter)
myButton.bind("<Leave>", on_leave)

root.mainloop()
Comment

change the color of the button on hovering tkinter

import tkinter as tk

class HoverButton(tk.Button):
    def __init__(self, master, **kw):
        tk.Button.__init__(self,master=master,**kw)
        self.defaultBackground = self["background"]
        self.bind("<Enter>", self.on_enter)
        self.bind("<Leave>", self.on_leave)

    def on_enter(self, e):
        self['background'] = self['activebackground']

    def on_leave(self, e):
        self['background'] = self.defaultBackground

root = tk.Tk()

classButton = HoverButton(root,text="Classy Button", activebackground='green')
classButton.grid()

root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: change column value based on another column pandas 
Python :: playsound moudle python 
Python :: pil overlay images 
Python :: python dataframe get numeric columns 
Python :: pythion code for finding all string lengths in a code 
Python :: error bar plot python 
Python :: scipy correlation 
Python :: how to make a button circular in python 
Python :: iterate through 2 strings python 
Python :: selenium python chrome path 
Python :: loop rought rows in pands 
Python :: decrypt python code 
Python :: store all files name in a folder python 
Python :: python selenium save cookies 
Python :: PIL Make Circle 
Python :: how to roll longitude coordinate 
Python :: join two numpy arrays 
Python :: python open folder 
Python :: semicolons in python 
Python :: read text file in python 
Python :: UnavailableInvalidChannel error in conda 
Python :: remove duplicates from list python 
Python :: python des 
Python :: read csv exclude index pandas 
Python :: pygame.key.get_pressed() 
Python :: pickle.load python 
Python :: find max value index in value count pandas 
Python :: spark add column to dataframe 
Python :: copy a file from one directroy to other using python 
Python :: take input in 2d list in python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =