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
-- http://mail.python.org/mailman/listinfo/python-list