टिंकर इवेंट किसी भी एप्लिकेशन के लिए बहुत उपयोगी होते हैं जहां हमें एक निश्चित कार्य या क्रिया करने की आवश्यकता होती है। टिंकर में, घटनाओं को आम तौर पर उस फ़ंक्शन को परिभाषित करके बनाया जाता है जिसमें कोड का टुकड़ा और निश्चित घटना के लिए तर्क होता है। ईवेंट को कॉल करने के लिए, हम आम तौर पर ईवेंट को कुछ कुंजियों या बटन विजेट से बाँधते हैं। बाइंड फ़ंक्शन दो पैरामीटर लेता है ('<कुंजी-संयोजन>', कॉलबैक) जो बटन को ईवेंट को ट्रिगर करने में सक्षम बनाता है।
निम्नलिखित उदाहरण में समान दृष्टिकोण का उपयोग करते हुए, हम कुंजी संयोजन
उदाहरण
# Import the required libraries
from tkinter import *
from tkinter import messagebox
# Create an instance of tkinter frame
win= Tk()
# Set the size of the tkinter window
win.geometry("700x350")
# Define a function to show the popup message
def show_msg(e):
messagebox.showinfo("Message","Hey There! I hope you are doing well.")
# Add an optional Label widget
Label(win, text = "Admin Has Sent You a Message. " "Press <Shift+Tab> to View the Message.", font = ('Aerial 15')).pack(pady= 40)
# Bind the Shift+Tab key with the event
win.bind('<Shift-Tab>', lambda e: show_msg(e))
win.mainloop() आउटपुट
जब हम उपरोक्त प्रोग्राम को निष्पादित करते हैं, तो यह एक लेबल विजेट वाली विंडो प्रदर्शित करेगा। जब हम कुंजी संयोजन
