mirroring text window to file

Anand B Pillai abpillai at lycos.com
Sat Apr 12 13:35:00 CEST 2003

Try this,

 In your program,
 class YourClass:


    def write(self, output):
       text_window.insert('end', output)

 sys.stdout = YourClass
This will direct all 'print' output to the
write method of your class which is the 
wrapper for the two methods you outlined.

Anand Pillai

Erik Max Francis <max at alcyone.com> wrote in message news:<3E978E80.AC7BA047 at alcyone.com>...
> Marcel Achim wrote:
> > I was wondering if there's an existing solution other than writing
> > to both a file and an output text window (Tk text widget), as in :
> > 
> >    text_window.insert('end', output)
> >    log_file.write(output)
> Write a wrapper class that does both.

More information about the Python-list mailing list