like all python codethe module in example - can be started in number of ways-by running it as top-level program filec:\pp \gui\intropython gui py by importing it from python session or another module fileimport gui by running it as unix executable if we add the special #line at the topgui py and in any other way python programs can be launched on your platform for instancethe script can also be run by clicking on the file' name in windows file explorerand its code can be typed interactively at the prompt ss it can even be run from program by calling the appropriate embedding api function (see for details on integrationin other wordsthere are really no special rules to follow when launching gui python code the tkinter interface (and tk itselfis linked into the python interpreter when python program calls gui functionsthey're simply passed to the embedded gui system behind the scenes that makes it easy to write command-line tools that pop up windowsthey are run the same way as the purely text-based scripts we studied in the prior part of this book avoiding dos consoles on windows in and we noted that if program' name ends in pyw extension rather than py extensionthe windows python port does not pop up dos console box to serve as its standard streams when the file is launched by clicking its filename icon now that we've finally started making windows of our ownthat filename trick will start to become even more useful if you just want to see the windows that your script makes no matter how it is launchedbe sure to name your gui scripts with pyw if they might be run on windows for instanceclicking on the file in example - in windows explorer creates just the window in figure - example - pp \gui\intro\gui pyw same as gui py ss tipas suggested earlierwhen typing tkinter gui code interactivelyyou may or may not need to call mainloop to display widgets this is required in the current idle interfacebut not from simple interactive session running in system console window in either casecontrol will return to the interactive prompt when you kill the window you created note that if you create an explicit main-window widget by calling tk(and attach widgets to it (described later)you must call this again after killing the windowotherwisethe application window will not exist climbing the gui learning curve