I am trying to redirect stdout into a Tkinter Text widget in real time using Python 2.7.2 on Windows 7. In my code below, I intended to have a print statement appear in the
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
Call sleepBtn.update_idletasks()
before each time.sleep(2)
command. Otherwise the view will not be updated before the end of the sleep procedure.
Instead of sleepBtn.update_idletasks()
, this may be a neater solution:
Put
self.text_area.update_idletasks()
before
self.text_area.insert(END, str)