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

前端 未结 3 454
情书的邮戳
情书的邮戳 2020-12-19 10:17

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

相关标签:
3条回答
  • 2020-12-19 10:32

    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

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

    0 讨论(0)
  • 2020-12-19 10:56

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

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

    0 讨论(0)
提交回复
热议问题