How to exit from Python using a Tkinter Button? How to exit from Python using a Tkinter Button? tkinter tkinter

How to exit from Python using a Tkinter Button?


There are two functions you should use to quit a window:

  • destroy()
  • quit()

Here you have the code using one of the two:

import Tkinterimport tkMessageBoximport timeimport sysdef endProgam():    # top.quit()    top.destroy()        top = Tkinter.Tk()B = Tkinter.Button(top, text = "Hello", command = endProgam)B.pack()top.mainloop()