redirect of standard output of jython to JTextArea
Jan Gregor
gregor.jan at NOSPAM.quick.cz
Thu Jan 27 07:53:45 EST 2005
problem solved.
in class:
sys.stdout = StdOutRedirector(self)
class StdOutRedirector:
def __init__(self, console):
self.console = console
def write(self, data):
#print >> sys.stderr, ">>%s<<" % data
if data != '\n':
# This is a sucky hack. Fix printResult
self.console.textArea.append(data)
Jan
Jan Gregor wrote:
> Hello
>
> I want to redirect output of jython's functions print and println to
> JTextArea component. Is it possible ?
>
> I tried this (swingConsole.textArea is instance):
>
> In my class
>
> self.printStream= MyPrintStream(System.out)
> System.setOut(self.printStream)
>
> ----------------------------------------------------
> class MyPrintStream (PrintStream):
>
> def println (str):
> swingConsole.textArea.append(str)
>
> def print (str):
> swingConsole.textArea.append(str)
>
>
> Output is still directed to standard output.
>
>
> Thanks for help,
> Jan
More information about the Python-list
mailing list