finallytkinter scripts can also register callback handlers to be run in special contextssuch as timer expirationsinput data arrivaland event-loop idle states scripts can also pause for state-change events related to windows and special variables we'll meet these event interfaces in more detail near the end of binding events of all the options listed in the prior sectionbind is the most generalbut also perhaps the most complex we'll study it in more detail laterbut to let you sample its flavor nowexample - rewrites the prior section' gui again to use bindnot the command keywordto catch button presses example - pp \gui\intro\gui py import sys from tkinter import def hello(event)print('press twice to exit'def quit(event)print('helloi must be going 'sys exit(on single-left click on double-left click event gives widgetx/yetc widget button(nonetext='hello event world'widget pack(widget bind(''hellobind left mouse clicks widget bind(''quitbind double-left clicks widget mainloop(in factthis version doesn' specify command option for the button at all insteadit binds lower-level callback handlers for both left mouse clicks (and doubleleft mouse clicks (within the button' display area the bind method accepts large set of such event identifiers in variety of formatswhich we'll meet in when runthis script makes the same window as before (see figure - clicking on the button once prints message but doesn' exityou need to double-click on the button now to exit as before here is the output after clicking twice and double-clicking once ( double-click fires the single-click callback first) :\pp \gui\intropython gui py press twice to exit press twice to exit press twice to exit helloi must be going although this script intercepts button clicks manuallythe end result is roughly the samewidget-specific protocols such as button command options are really just higherlevel interfaces to events you can also catch with bind graphical user interfaces