TkMessageBox doesn't close after clicking OK

864 views Asked by At

I have the following code, which should open a popup window. Now, if the user click "Yes" in the popup, it should show the main program window, and otherwise exit:

import tkMessageBox
from Tkinter import *

root = Tk()
root.withdraw()  # hide the main program window

if not tkMessageBox.askyesno("Title",
                             "Do you want to start the program now?"):
    # If the user pressed the 'No' botton
    root.destroy()
    exit(0)

print "test"

text = Text(root)
text.insert(INSERT, "Hello")
text.pack()

root.deiconify()  # show the main program window
root.mainloop()

When I run it and click on the "Yes" button in the popup, I see that "test" is outputted to the terminal, but the popup freezes and I don't see the main program window with the text element. I have looked at Tkinter TkMessageBox not closing after click OK, but it didn't help me. Does anybody have a solution to this problem?

0

There are 0 answers