From: Ype K. <yk...@xs...> - 2002-01-30 09:17:18
|
Hugh, >Hello - > >I have written a Java GUI that loads a Jython script and then attempts to run it >using an embedded Jython interpreter, i.e., the PythonInterpreter class and/or >the InteractiveInterpreter class. > >I have been unable to capture the output of the script as it runs so I can >display its progress in my Java GUI. Using the InteractiveInterpreter I sent the >Jython script to the embedded interpreter line-by-line and caputer the output by >using the setOut() method with a StringWriter output stream. This worked for the >"topmost" Jython script, but when the executing script called my functions that >were defined in another Jython script (which it found), the output stopped being >retrieved until the entire script ran to completion. And I have yet to figure >out how to capture the output when I use the PythonInterpreter.exec(String s) >method. >Any ideas? I'm stumped. Have a look at console.py in the demo/swing directory for an example of how to do this in jython. Basically you have to replace sys.stdout with another object that has some methods to receive the data. >Thanks! My pleasure. Ype -- |