non-gui connects to it or the non-gui script will be denied connection and will fail because of the buffered text nature of the socket makefile objects used for streams herethe client program is required to flush its printed output with sys stdout flush to send data to the gui--without this callthe gui receives and displays nothing as we'll learn in this isn' required for command pipesbut it is when streams are reset to wrapped sockets as done here these wrappers don' support unbuffered modes in python xand there is no equivalent to the - flag in this context (more on - and command pipes in the next sectionstay tuned for much more on this example and topic in its socket clientserver model works well and is general approach to connecting gui and non-gui codebut there are other coding alternatives worth exploring in the next section before we move on adding gui as separate programcommand pipes the net effect of the two programs of the preceding section is similar to gui program reading the output of shell command over pipe file with os popen (or the subprocess popen interface upon which it is basedas we'll see laterthoughsockets also support independent serversand can link programs running on remote machines across network-- much larger idea we'll be exploring in perhaps subtler and more significant for our gui exploration here is the fact that without an after timer loop and nonblocking input sources of the sort used in the prior sectionthe gui may become stuck and unresponsive while waiting for data from the non-gui program and may not be able to handle more than one data stream for instanceconsider the guistreams call we wrote in example - to redirect the output of shell command spawned with os popen to gui window we could use this with simplistic code like that in example - to capture the output of spawned python program and display it in separately running gui program' window this is as concise as it is because it relies on the read/write loop and guioutput class in example - to both manage the gui and read the pipeit' essentially the same as one of the options in that example' self-test codebut we read the printed output of python program here example - pp \gui\tools\pipe-gui py gui reader sideroute spawned program standard output to gui window from pp gui tools guistreams import redirectedguishellcmd redirectedguishellcmd('python - pipe-nongui py' gui coding techniques uses guioutput -uunbuffered