How to redirect in real time STDOUT from imported module to Tkinter Text Widget in python? How to redirect in real time STDOUT from imported module to Tkinter Text Widget in python? tkinter tkinter

How to redirect in real time STDOUT from imported module to Tkinter Text Widget in python?


Call sleepBtn.update_idletasks() before each time.sleep(2) command. Otherwise the view will not be updated before the end of the sleep procedure.


I made a class which copies stdout write calls to a tkinter widget be it a Label or a Text. Works for me on Python3.3.1/WindowsXp.:

https://stackoverflow.com/a/16460878/2334951


Instead of sleepBtn.update_idletasks(), this may be a neater solution:

Putself.text_area.update_idletasks()before self.text_area.insert(END, str)