किसी विशेष एप्लिकेशन के लिए, यदि हम उसमें परिभाषित बटनों की मदद से कई कार्य करना चाहते हैं, तो हम बाइंड (बटन, कॉलबैक) का उपयोग कर सकते हैं। विधि जो एप्लिकेशन में ईवेंट के चलने को शेड्यूल करने के लिए बटन और ईवेंट को एक साथ बांधती है।
मान लें कि हम एक
उदाहरण
# 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() आउटपुट
यदि हम उपरोक्त कोड चलाते हैं, तो यह एक विंडो प्रदर्शित करेगा जिसमें एक बटन होगा।

जब हम बटन पर होवर करते हैं, तो यह लेबल की पृष्ठभूमि का रंग बदल देगा। बटन छोड़ने से लेबल विजेट का फ़ॉन्ट रंग बदल जाएगा।
