What is the difference between root.destroy() and root.quit()?

前端 未结 4 1030
北荒
北荒 2020-11-28 12:49

In Python using tkinter, what is the difference between root.destroy() and root.quit() when closing the root window?

Is one pr

4条回答
  •  情深已故
    2020-11-28 13:16

    My experience with root.quit() and root.destroy() ...

    I have a dos python script, which calls a tkinter script (to choose from set of known values from combobox), then returns to the dos script to complete other things.

    The TKinter script I've added onto the parent script. I may convert all to tkinter, but a combo works for the time being. It works in the following way:

    To get rid of the windows box after selection was implemented, I needed to
    1) root.quit() inside the callback function where all my keypresses were being processed.
    2) root.destroy() after mainloop to destroy the windows box.

    If I used root.destroy() inside the callback, I got an error message saying tkinter objects were no longer accessable.

    Without the root.destroy() after mainloop, the windows box STAYED ONSCREEN until the whole parent script had completed.

提交回复
热议问题