aditya rawat
aditya rawat

Reputation: 115

Python - Could not Exit from Tkinter using Menu.quit

I am currently learning python tkinter and have an issue regarding quiting tkinter window using explicit code. Here's my code so far (I've simplified it to focus on the problem only)

from tkinter import *

def DoSomething():
    pass

root = Tk()
men = Menu(root)
root.config(menu = men)
submenu = Menu(men)
men.add_cascade(label = "File",menu = submenu)

submenu.add_command(label = "quit",command = Menu.quit)#Window does not close when user clicks "quit",
                                                       it just 
                                                       stays there non-responding

root.mainloop()

Any help regarding this is appreciated. Thanks

Upvotes: 2

Views: 1148

Answers (1)

Adophilus
Adophilus

Reputation: 310

in python tkinter you're supposed to use the 'destroy' method to get rid of the tkinter window,i.e:

submenu.add_command(label="quit",command=root.destroy)

In your case.

Upvotes: 5

Related Questions