(pun nearly accidentalin other wordswon' help--it doesn' support the goal of verifying saves on window closesand it doesn' address the issue of quit and destroy calls run for widgets outside the scope of pyedit window classes because of such complicationspyedit instead relies on checking for changes in each individual window before closedand for changes in its cross-process window list before quits in any of its main windows applications that follow its expected window model check for changes automatically applications that embed pyedit as component of larger guior use it in other ways that are outside pyedit' controlare responsible for testing for edit changes on closes if they should be savedbefore the pyedit object or its widgets are destroyed to experiment with the event' behavior yourselfsee file destroyer py in the book examples packageit simulates what pyedit would need to do on here is the crucial subset of its codewith comments that explain behaviordef ondeleterequest()print('got wm delete'root destroy(def dorootdestroy(event)print('got event 'if event widget =textprint('for text'print(text edit_modified()ans askyesno('save stuff?''save?'if ansprint(text get(' 'end+'- ')on window xcan cancel destroy triggers called for each widget in root <tcl errorinvalid widget <may behave badly <tcl errorinvalid widget root tk(text text(rootundo= autoseparators= text pack(root bind(''dorootdestroyroot protocol('wm_delete_window'ondeleterequestfor root and children on window button button(roottext='destroy'command=root destroypack(button(roottext='quit'command=root quitpack(mainloop(triggers <fatal python errorno on quit(see the code listings in the next section for more on all of the above also be sure to see the mail file' documentation string for list of suggested enhancements and open issues (noted under "tbd"pyedit is largely designed to work according to my preferencesbut it' open to customization for yours pyedit source code the pyedit program consists of only small configuration module and one main source filewhich is just over , lines long-- py that can be either run or imported for pyedita text editor program/object