tkinter won't quit when I press quit button, it just changes location
<p>This is the code and when I run it the quit button doesn't work:</p>

<pre class="lang-py prettyprint-override"><code>def quit2():

    menu.destroy()
def menu1():

    menu=Tk()
    global menu
    play=Button(menu, text='play', command =main)
    play.pack()
    quit1=Button(menu, text='quit', command=quit2)
    quit1.pack()
    menu.mainloop()

while True:

    menu1()
</code></pre>

<p>You use <code>while True</code> so after you close window <code>while True</code> opens new window.</p>

<p>Use last line <code>menu1()</code> without <code>while True</code></p>

<p><strong>EDIT:</strong></p>

<pre><code>from tkinter import *

def quit2():
    menu.destroy()

def menu1():
    global menu

    menu = Tk()

    play = Button(menu, text='play', command=main)
    play.pack()
    quit1 = Button(menu, text='quit', command=quit2)
    quit1.pack()

    menu.mainloop()

#without `while True`
menu1()
</code></pre>

python tkinter