📅  最后修改于: 2022-03-11 14:59:11.859000             🧑  作者: Mango
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("", on_enter)
myButton.bind("", on_leave)
root.mainloop()