import tkinter as tk
class ExtendedButton(tk.Button):
def __init__(self, master=None, **kw):
tk.Button.__init__(self, master=master, **kw)
self.bind("<Enter>", self._on_enter)
self.bind("<Leave>", self._on_leave)
def _on_enter(self, event):
self.config(bg="red")
def _on_leave(self, event):
self.config(bg=self.cget("background"))
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
import tkinter as tk
class ExtendedButton(tk.Button):
def __init__(self, master=None, **kw):
tk.Button.__init__(self, master=master, **kw)
self.bind("<Enter>", self._on_enter)
self.bind("<Leave>", self._on_leave)
def _on_enter(self, event):
self.config(bg="red")
def _on_leave(self, event):
self.config(bg=self.cget("background"))