Python: tkinter askyesno method opens an empty window
Tkinter requires that a root window exist before you can create any other widgets, windows or dialogs. If you try to create a dialog before creating a root window, tkinter will automatically create the root window for you.
The solution is to explicitly create a root window, then withdraw it if you don't want it to be visible.
You should always create exactly one instance of Tk
, and your program should be designed to exit when that window is destroyed.
Create root window explicitly, then withdraw.
from Tkinter import *from tkMessageBox import *Tk().withdraw()askyesno('Verify', 'Really quit?')
Not beautiful solution, but it works.
UPDATE
Do not create the second Tk window.
from Tkinter import *from tkMessageBox import *root = Tk()root.withdraw()showinfo('OK', 'Please choose')root.deiconify()# Do not create another Tk window. reuse root.root.title("Report month")...