简体   繁体   中英

Tkinter window doesn't destroy after pressing Quit once, have to press Quit 4 times to close window

I'm using the Tkinter module in python, with that I make a calculator doing the basic functions for a calculator. So there is a total of 5 different functions, using Object-oriented programming. The issue I'm having is I implement the Quit widget so it destroys the main window when pressed. But when I press it, I have to press quit a total of 4 times before the window is closed.

I would put all of my code but I'm not sure where the issue is and wanted to see any ideas you all say then ill put in the specific code.

self.quit = Button(self.bottom,text = 'Quit',command = self.main.destroy)

This is the line of code that executes to close the window using destroy. 'main' is the title of the window. 'bottom' is the fourth row.

If you require I put in all my code then I will, I just didn't want to put in 30-40 lines of code and it could be anywhere.

Is it possible since I have 5 frames, that the destroy function closes the first 3 first then finally closes the window that has quit?

Here are a few things you could try:

  • Make sure to call destroy() from the root window.
  • Try pressing quit once and waiting. I've had a similar problem in older machines where I'd press a button and it would take 5 whole seconds to it to respond.

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