Threaded Tkinter script crashes when creating the second Toplevel widget

后端 未结 3 753
深忆病人
深忆病人 2020-11-28 14:00

I have a Python script which uses Tkinter for the GUI. My little script should create a Toplevel widget every X seconds. When I run my code, the first Toplevel widget is cre

3条回答
  •  爱一瞬间的悲伤
    2020-11-28 14:17

    Is there a reason you want (or think you need) one event loop per toplevel window? A single event loop is able to handle dozens (if not hundreds or thousands) of toplevel windows. And, as has been pointed out in another answer, you can't run this event loop in a separate thread.

    So, to fix your code you need to only use a single event loop, and have that run in the main thread.

提交回复
热议问题