简体   繁体   中英

tkinter window isn't closing

I created a save dialog to use with my pygame file, however, after the save dialog is shutdown, the small blank tk window isn't shutting down.

Here is my code

root = Tk()
def save():
    filename = filedialog.asksaveasfilename(title="Save",defaultextension=".jpg")
    return filename

root.destroy()
root.mainloop()

There can be a lot of reasons why this is happening. Use the following in whichever function, you want to close EVERYTHING (from your question, I'm guessing that you want to do that) in your program:

sys.exit()   #if this doesn't work, "import sys" first

Let me know if this also, doesn't work (it should).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM