print('end of file'root tk(button(roottext='test streams'command=lambdaredirectedguifunc(makeupper)pack(fill=xbutton(roottext='test files 'command=lambdamakelower(guiinput()guioutput()pack(fill=xbutton(roottext='test popen 'command=lambdaredirectedguishellcmd('dir *')pack(fill=xroot mainloop(as coded hereguioutput attaches scrolledtext (python' standard library flavorto either passed-in parent container or new top-level window popped up to serve as the container on the first write call guiinput pops up new standard input dialog every time read request requires new line of input neither one of these policies is ideal for all scenarios (input would be better mapped to more long-lived widget)but they prove the general point intended figure - shows the scene generated by this script' self-test codeafter capturing the output of windows shell dir listing command (on the leftand two interactive loop tests (the one with "line?prompts and uppercase letters represents the makeupper streams redirection testan input dialog has just popped up for new makelower files interface test figure - guistreams routing streams to pop-up windows this scene may not be spectacular to look atbut it reflects file and stream input and output operations being automatically mapped to gui devices--as we'll see in momentthis accomplishes most of the solution to the prior section' closing challenge before we move onwe should note that this module' calls to redirected function as well as its loop that reads from spawned shell command are potentially blocking- gui coding techniques