สำหรับแอปพลิเคชันเฉพาะ หากเราต้องการทำงานหลายอย่างโดยใช้ปุ่มที่กำหนดไว้ในนั้น เราก็สามารถใช้ ผูก (ปุ่ม โทรกลับ) วิธีการซึ่งผูกปุ่มและเหตุการณ์เข้าด้วยกันเพื่อกำหนดเวลาการทำงานของเหตุการณ์ในแอปพลิเคชัน
สมมติว่าเราต้องการผูกหลายเหตุการณ์หรือการเรียกกลับด้วย
ตัวอย่าง
# 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):
label.config(background="#adad12")
def change_fgcolor(e):
label.config(foreground="white")
# Add a Label widget
label = Label(win, text="Hello World! Welcome to Tutorialspoint", font=('Georgia 19 italic'))
label.pack(pady=30)
# Add Buttons to trigger the event
b1 = ttk.Button(win, text="Button-1")
b1.pack()
# Bind the events
for b in [b1]:
b.bind("<Enter>", change_bgcolor)
b.bind("<Leave>", change_fgcolor)
win.mainloop() ผลลัพธ์
หากเราเรียกใช้โค้ดข้างต้น จะแสดงหน้าต่างที่มีปุ่ม

เมื่อเราวางเมาส์เหนือปุ่ม มันจะเปลี่ยนสีพื้นหลังของป้ายกำกับ การออกจากปุ่มจะเปลี่ยนสีแบบอักษรของวิดเจ็ตป้ายกำกับ
