blocking makes this redirectedguishellcmd much more generally useful than the original pipe version we coded compared to the sockets of the prior sectionthoughthis solution is bit of mixed bagbecause this gui reads the spawned program' standard outputno changes are required in the non-gui program unlike the socket-based example in the prior sectionthe non-gui program here needs no knowledge of the gui that will display its results--it need not connect to socket and need not flush its input streamas required for the earlier socket-based option although it requires no changes to the programs whose output is displayedthe gui code' complexity begins to approach that of the socket-based alternativeespecially if you strip away the boilerplate code required for all socket programs it does not directly support running the gui and non-gui programs separatelyor on remote machines as we'll see in sockets allow data to be passed between programs running on the same machine or across networks sockets apply to more use cases than displaying program' output stream if the gui must do more than display another program' outputsockets become more general solution--as we'll also learn laterbecause sockets are bidirectional data streamsthey allow data to be passed back and forth between two programs in more arbitrary ways other uses for threaded pipe guis despite its tradeoffsthe thread/queue/pipe-based approach for guis has fairly wide applicability to illustratehere' another quick usage example the following runs simple script normally from shell/terminal windowit prints one successively longer output line every two secondsc:\pp \gui\toolstype spams py import time for in range( )time sleep( print to standard output print('spaminothing gui about thisehc:\pp \gui\toolspython spams py spam spamspamspam spamspamspamspamspam spamspamspamspamspamspamspam spamspamspamspamspamspamspamspamspam let' wrap this up in guiwith code typed at the interactive prompt for variety the following imports the new gui redirection function as library component and uses it to create window that displays the script' five linesappearing every two seconds just as in the terminal windowfollowed by final line containing reflecting the spawned program' exit the resulting output window is captured in figure - gui coding techniques