the gui script is trivial examplebut it illustrates steps common to most tkinter programs this python code does the following loads widget class from the tkinter module makes an instance of the imported label class packs (arrangesthe new label in its parent widget calls mainloop to bring up the window and start the tkinter event loop the mainloop method called last puts the label on the screen and enters tkinter wait statewhich watches for user-generated gui events within the mainloop functiontkinter internally monitors things such as the keyboard and mouse to detect usergenerated events in factthe tkinter mainloop function is similar in spirit to the following pseudo-python codedef mainloop()while the main window has not been closedif an event has occurredrun the associated event handler function because of this modelthe mainloop call in example - never returns to our script while the gui is displayed on-screen +when we write larger scriptsthe only way we can get anything done after calling mainloop is to register callback handlers to respond to events this is called event-driven programmingand it is perhaps one of the most unusual aspects of guis gui programs take the form of set of event handlers that share saved information rather than of single main control flow we'll see how this looks in terms of real code in later examples note that for code in script fileyou really need to do steps and in the preceding list to open this script' gui to display gui' window at allyou need to call main loopto display widgets within the windowthey must be packed (or otherwise arrangedso that the tkinter geometry manager knows about them in factif you call either mainloop or pack without calling the otheryour window won' show up as expecteda mainloop without pack shows an empty windowand pack without mainloop in script shows nothing since the script never enters an event wait state (try itthe mainloop call is sometimes optional when you're coding interactivelybut you shouldn' rely on this in general since the concepts illustrated by this simple script are at the core of most tkinter programslet' take deeper look at some of them before moving on +technicallythe mainloop call returns to your script only after the tkinter event loop exits this normally happens when the gui' main window is closedbut it may also occur in response to explicit quit method calls that terminate nested event loops but leave open the gui at large you'll see why this matters in climbing the gui learning curve