You may occasionally need to redirect the output of a command line to a GUI such as Tkinter. The ability to pass outputs from the command line to Tkinter opens a large pool of possibilities for using the inherent powers of the shell on Unix and Linux operating systems and the Windows shell on a Windows machine.
We will demonstrate this by using the subprocess Python module, which lets us spawn new processes, connect to the input, output, and error pipes of this new process, and obtain the return codes from the programs.
A detailed discussion on the subprocess module can be found at https://docs.python.org/3/library/subprocess.html.
We will use the Popen class from the subprocess module to create a new process.
The Popen class provides a cross-platform way to create new processes, and it has the following long signature to handle most...