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

前端 未结 4 1029
北荒
北荒 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 12:59

    root.quit() causes mainloop to exit. The interpreter is still intact, as are all the widgets. If you call this function, you can have code that executes after the call to root.mainloop(), and that code can interact with the widgets (for example, get a value from an entry widget).

    Calling root.destroy() will destroy all the widgets and exit mainloop. Any code after the call to root.mainloop() will run, but any attempt to access any widgets (for example, get a value from an entry widget) will fail because the widget no longer exists.

提交回复
热议问题