Tkinter มีวิธีผูกวิดเจ็ตเพื่อดำเนินการบางอย่าง การดำเนินการเหล่านี้ถูกกำหนดในฟังก์ชันที่สามารถเรียกใช้โดยวิดเจ็ตเฉพาะ bind( เมธอดใช้เพื่อผูกแป้นคีย์บอร์ดเพื่อจัดการกับการดำเนินการดังกล่าว นอกจากนี้เรายังสามารถผูกคีย์เฉพาะเพื่อจัดการกับเหตุการณ์บางอย่างสำหรับวิดเจ็ตปุ่มได้
ตัวอย่าง
#Import tkinter library
from tkinter import *
from tkinter import ttk
#Create an instance of Tkinter frame or window
win = Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
def callback():
Label(win, text="Hello World!", font=('Georgia 20 bold')).pack(pady=4)
#Create a Label and a Button widget
btn = ttk.Button(win, text="Press Enter to Show a Message", command= callback)
btn.pack(ipadx=10)
win.bind('<Return>',lambda event:callback())
win.mainloop() ผลลัพธ์
การรันโค้ดด้านบนจะแสดงหน้าต่างที่ประกอบด้วยปุ่ม

เมื่อเรากดปุ่ม "Enter" จะแสดงข้อความบนหน้าจอ