Tkinter의 버튼 위젯에는 애플리케이션에서 특정 작업을 구성하고 수행하는 데 사용할 수 있는 많은 내장 기능이 있습니다. 애플리케이션에서 특정 이벤트를 실행하기 위해 bind("
예시
# Import the required libraries
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame or window
win=Tk()
# Set the size of the window
win.geometry("700x350")
def change_bgcolor(e):
win.config(background="green3")
def change_fgcolor(e):
win.config(background="white")
# Add Buttons to trigger the event
b1=Button(win, text="Hover on Me", font=('Georgia 16'))
b1.pack(pady=60,anchor=CENTER)
# Bind the events
for b in [b1]:
b.bind("<Enter>",change_bgcolor)
b.bind("<Leave>", change_fgcolor)
win.mainloop() 출력
위의 코드를 실행하면 버튼이 포함된 창이 표시됩니다.

버튼 위에 마우스를 올리면 메인 창의 배경색이 바뀝니다.
