Tkinter에서 이벤트는 일반적으로 버튼이나 키로 호출됩니다. 사용자가 할당된 키를 누르거나 할당된 버튼을 클릭할 때마다 이벤트가 실행됩니다. 이벤트를 실행하기 위해 버튼이나 키를 콜백 함수로 바인딩할 수 있습니다.
마우스 버튼을 놓을 때마다 이벤트를 트리거해야 하는 애플리케이션을 고려하십시오. 이것은 를 전달하여 달성할 수 있습니다. bind(
예시
# Import the required libraries
from tkinter import *
# Create an instance of tkinter frame or window
win=Tk()
# Set the size of the window
win.geometry("700x350")
# Define a function on mouse button clicked
def on_click(event):
label["text"]="Hello, There!"
def on_release(event):
label["text"]="Button Released!"
# Crate a Label widget
label=Label(win, text="Click anywhere..", font=('Calibri 18 bold'))
label.pack(pady=60)
win.bind("<ButtonPress-1>", on_click)
win.bind("<ButtonRelease-1>", on_release)
win.mainloop() 출력
위의 코드를 실행하면 레이블 위젯이 있는 창이 표시됩니다.

이제 창의 아무 곳이나 클릭하면 화면에서 마우스 버튼을 놓을 때 업데이트될 메시지를 볼 수 있습니다.

마우스 버튼을 놓으면 다음 메시지가 표시됩니다 -
