Write to terminal in Tkinter GUI Write to terminal in Tkinter GUI tkinter tkinter

Write to terminal in Tkinter GUI


Well you are in the right module at least. subprocess also contains utilities for viewing the output of the command that you run, so that you can have the output of your perl script made available to you.

If you want to simply get all of the subprocesses output after it finishes running, use subrocess.check_output(). It should be more than sufficient.

However, if the subtask is a long running program or you require monitoring in real-time, you should really look at the Popen class in the subprocess module. You can create and monitor a new process like this:

import subprocessp = subprocess.Popen("perl /projects/tfs/users/$USER/scripts_coverage.pl", stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = True)   while True:    line = p.stdout.readline()    print line    if not line: break

From there you could echo the output into a terminal or use a Tkinter widget to display the rolling program output. Hope this helps.