From: Jeff E. <JEm...@lg...> - 2004-09-18 00:02:40
|
=20 You need to override the write method of OutputStream. Jython doesn't = call the println method. =20 ________________________________ From: jyt...@li... on behalf of Reinhard = Engels Sent: Fri 9/17/2004 5:08 PM To: jyt...@li... Subject: [Jython-users] interp.setOut( outputStream ) doesn't work Warning: complete newbie here. I've embedded a PythonInterpreter in my gui app and was amazed at how = easy this was. Just one problem: I can't figure out how to capture the output and display it to the user in a TextPane. I've seen a few questions about this in the archive but no = straightforward answers. Sorry in advance if I'm just being thick. Seems like it should = be a really simple thing to do. I have no trouble redirecting ordinary System.out and System.err to a gui component. Here is the gui updating class: public class GuiStream extends PrintStream { public GuiStream(OutputStream outputStream,JTextComponent component){ super(outputStream); m_component =3D component; } public void println(String string){ m_component.setText(m_component.getText()+"\n" + = string); } protected JTextComponent m_component; } The following call makes it print out System.out/err, and works just = fine: m_guiStream =3D new GuiStream(System.out,m_textPane); System.setOut(m_guiStream); System.setErr(m_guiStream); The following call does *NOT* make PythonInterpreter redirect its = output: m_jython.setOut(m_guiStream); m_jython.setErr(m_guiStream); Thanks in advance, Reinhard http://www.broad.mit.edu/annotation/argo/ ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Jython-users mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-users |