Page 354 -
P. 354
graphical interface elements
Not all events are generated by button clicks
Your GUI program processes lots of events, not just the events generated by your
user when, for instance, buttons are clicked.
Your operating system can send events to your GUI program, too. Some of these
events are commonly handled by the graphical programming technology you
are working with. For most of the operating system’s events, tkinter very kindly
handles them for you. When you click the close box on your GUI, this generates a
Window Manager event for your code to handle. If your code doesn’t handle a
Window Manager event, tkinter handles it for you in a default way, too.
Your user
generates a
button-click
event in the
GUI. Click!
Wait for another event. Run the event-handling code
associated with whatever
event occurred or perform
some default action.
Click!
The Window Manager
generates an event
when the user clicks
on the close box.
If the default event handling isn’t what you want, you have to capture the event
before it gets to tkinter and is handled in the default way. At the moment, the click
on the close box is being handled for you by tkinter and the default behavior is to
close the window.
Let's take control of this default behavior.
you are here 4 319