data is discarded if the python image object is garbage collected tkinter variable class objects also temporarily unset an associated tk variable if reclaimedbut this is uncommon and less harmful adding buttons and callbacks so farwe've learned how to display messages in labelsand we've met tkinter core concepts along the way labels are nice for teaching the basicsbut user interfaces usually need to do bit more like actually responding to users to show howthe program in example - creates the window in figure - example - pp \gui\intro\gui py import sys from tkinter import widget button(nonetext='hello widget world'command=sys exitwidget pack(widget mainloop(figure - button on the top hereinstead of making labelwe create an instance of the tkinter button class it' attached to the default top level window as before on the default top packing side but the main thing to notice here is the button' configuration argumentswe set an option called command to the sys exit function for buttonsthe command option is the place where we specify callback handler function to be run when the button is later pressed in effectwe use command to register an action for tkinter to call when widget' event occurs the callback handler used here isn' very interestingas we learned in the built-in sys exit function simply shuts down the calling program herethat means that pressing this button makes the window go away just as for labelsthere are other ways to code buttons example - is version that packs the button in place without assigning it to nameattaches it to the left side of its parent window explicitlyand specifies root quit as the callback handler-- standard tk object method that shuts down the gui and so ends the program technicallyquit ends the current mainloop event loop calland thus the entire program herewhen adding buttons and callbacks