From 03a075b340494cb3884e33c0c70efb1905d73a30 Mon Sep 17 00:00:00 2001 From: MaharishiCanada Date: Tue, 31 Dec 2019 17:23:45 -0500 Subject: [PATCH] bpo-39171: In simpledialog.py _QueryDialog, missing _default_root * The programmer has to create the root himself and then withdraw it. * In a similar situation, the moduke ttk creates the root automatically. --- Lib/tkinter/simpledialog.py | 10 +++++++++- .../2019-12-31-19-06-02.bpo-39171.cmXDsX.rst | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-12-31-19-06-02.bpo-39171.cmXDsX.rst diff --git a/Lib/tkinter/simpledialog.py b/Lib/tkinter/simpledialog.py index 85244171117b61e..1927cf821bd6c7e 100644 --- a/Lib/tkinter/simpledialog.py +++ b/Lib/tkinter/simpledialog.py @@ -260,7 +260,15 @@ def __init__(self, title, prompt, parent = None): if not parent: - parent = tkinter._default_root + 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") self.prompt = prompt self.minvalue = minvalue diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-12-31-19-06-02.bpo-39171.cmXDsX.rst b/Misc/NEWS.d/next/Core and Builtins/2019-12-31-19-06-02.bpo-39171.cmXDsX.rst new file mode 100644 index 000000000000000..c3dfae4a2ad6e47 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-12-31-19-06-02.bpo-39171.cmXDsX.rst @@ -0,0 +1 @@ +Creating missing parent in tkinter simpledialog when possible.