title: How to exit from Python using a Tkinter Button?
body: <p>To start off, let me show you my code:</p>
  
  <pre><code>import Tkinter
  import tkMessageBox
  import time
  import sys
  
  def endProgam():
      raise SystemExit
      sys.exit()
  
  top = Tkinter.Tk()
  B = Tkinter.Button(top, text = "Hello", command = endProgam)
  B.pack()
  top.mainloop()
  </code></pre>
  
  <p>As you can see under <code>endProgram()</code> I have tried 2 types of exit commands, both do not work. I never used them together, I was just trying to show what methods I have used so far. These methods were methods I found here and on other websites, but if I try either, I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\Sa'id\Documents\Learning Programming\Python\Tkinter Tuts.py", line 22, in &lt;module&gt;
      top.mainloop()
    File "C:\Python27\lib\lib-tk\Tkinter.py", line 1070, in mainloop
      self.tk.mainloop(n)
    File "C:\Python27\lib\lib-tk\Tkinter.py", line 1488, in __call__
      raise SystemExit, msg
  SystemExit
  </code></pre>
  
  <p>I can't seem to find a fix to this and I was hoping maybe someone here could help me. If you need any more details I will gladly provide what you need.</p>