[issue39171] Missing default root in tkinter simpledialog.py
Dominic Mayers
report at bugs.python.org
Tue Dec 31 17:08:04 EST 2019
Dominic Mayers <dominic_mayers at yahoo.com> added the comment:
Again, I just spent a few minutes looking at this, but in the ttk module, in a similar situation, they do:
if master is None:
if tkinter._support_default_root:
master = tkinter._default_root or tkinter.Tk()
else:
raise RuntimeError(
"No master specified and tkinter is "
"configured to not support default root")
Why not do the same for _QueryDialog in simpledialog.py? Actually, I would also withdraw the root that was just created, because the user doesn't expect this extra window. So, I would replace
if not parent:
parent = tkinter._default_root
with
if parent is None:
if tkinter._default_root:
parent = tkinter._default_root
elif tkinter._support_default_root
parent = tkinter.Tk()
parent.withdraw()
else:
raise RuntimeError(
"No parent specified and tkinter is "
"configured to not support default root")
This tries to get a parent, if possible, and provides a more useful message when no parent can be found, just as in the ttk module in a similar situation.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39171>
_______________________________________
More information about the Python-bugs-list
mailing list