Segmentation fault while redirecting sys.stdout to Tkinter.Text widget

前端 未结 2 1541
暖寄归人
暖寄归人 2021-02-06 11:51

I\'m in the process of building a GUI-based application with Python/Tkinter that builds on top of the existing Python bdb module. In this application, I want to silence all std

2条回答
  •  囚心锁ツ
    2021-02-06 12:38

    I'm assuming this is part of a larger, threaded program.

    Instead of using a lock, have your code write to a thread-safe queue object. Then, in your main thread you poll the queue and write to the text widget. You can do the polling using the event loop (versus writing your own loop) by running the polling job which reschedules itself to run a few ms later using after (a couple hundred ms is probably quite sufficient).

提交回复
热议问题