-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
bpo-39171: Missing root in tkinter simpledialog.py _QueryDialog #17775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a new Tk instance is being created, I am of the opinion it should be explicitly deleted once we are done with the dialog (we shouldn't rely on the GC to clean it).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thought, would it be better to mimic tkinter.commondialog (for consistency), which doesn't withdraw or delete a new window?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about that too. It was a few months ago, but I remember to have compared with what is done elsewhere and came to the same conclusion. |
||
| else: | ||
| raise RuntimeError( | ||
| "No parent specified and tkinter is " | ||
| "configured to not support default root") | ||
|
|
||
| self.prompt = prompt | ||
| self.minvalue = minvalue | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Creating missing parent in tkinter simpledialog when possible. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this be better suited to the "library" part of the news?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know much about these aspects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend changing this to an explicit check for "not None"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The only reason why I did not do it, is to make as little change as possible.