GeezerVison is showing github.com — gh-59396: Modernize tkinter.simpledialog by serhiy-storchaka · Pull Request #151848 · python/cpython
Conversation
serhiy-storchaka
commented
Jun 21, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
This reworks tkinter.simpledialog to match the look and feel of the native Tk dialogs: SimpleDialog is a port of ::tk_dialog, and Dialog is a base class whose button box is modelled on ::tk::MessageBox.
SimpleDialog, askinteger, askfloat and askstring now use the themed tkinter.ttk widgets by default; the Dialog base class still defaults to the classic widgets for compatibility. Both classes gained a keyword-only use_ttk parameter to select the widget set.
- Both dialogs follow the message-box keyboard conventions: button accelerators (
Alt + the underlined letter), a default ring that follows the keyboard focus, and <Return> that invokes the focused button.
SimpleDialog gained bitmap and detail parameters, draws the standard icons with themed images in the ttk version, and accepts mappings of button options as buttons entries.
- The message and detail font and wrap length are taken from the Tk option database and can be overridden by the application.
- The new helpers
_temp_grab_focus, _underline_ampersand and _find_alt_key_target can be reused by other tkinter dialogs, as _setup_dialog already is.
- Several bugs found by comparison with the Tcl sources were fixed.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Rework SimpleDialog and Dialog to match the look and feel of the native Tk
dialogs ::tk_dialog and ::tk::MessageBox.
* SimpleDialog is a Python port of ::tk_dialog and Dialog a base class
modelled on ::tk::MessageBox. Both adopt the message-box keyboard
conventions: button accelerators, a default ring that follows the keyboard
focus, and a <Return> binding that invokes the focused button.
* Both classes gain a use_ttk parameter that selects the classic Tk or the
themed ttk widgets. It controls the widget set and the appearance that the
two procedures style differently, but not the keyboard behaviour.
* Update _place_window with the Tk 9.1 placement refinements.
* The new helpers _temp_grab_focus (a modal grab/focus context manager),
_underline_ampersand and _find_alt_key_target (ports of the Tk
accelerator-key procedures) can be reused by other tkinter dialogs, as
_setup_dialog already is.
* Fix several defects uncovered while comparing with the Tcl sources.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts:
# Doc/library/dialog.rst
# Lib/test/test_tkinter/test_simpledialog.py
Add a button per dialog, a checkbox to toggle classic/themed widgets, and
show a bitmap, a detail message and Alt-key button accelerators in the
SimpleDialog example.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
# Conflicts:
# Doc/whatsnew/3.16.rst
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jun 23, 2026
|
Thanks for doing this; IDLE has a few uses. Not much change on Windows but much better on macOS.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pyctrl
pushed a commit
to pyctrl/cpython
that referenced
this pull request
Jul 5, 2026
Rework SimpleDialog and Dialog to match the look and feel of the native Tk
dialogs ::tk_dialog and ::tk::MessageBox.
* SimpleDialog is a Python port of ::tk_dialog and Dialog a base class
modelled on ::tk::MessageBox. Both adopt the message-box keyboard
conventions: button accelerators, a default ring that follows the keyboard
focus, and a <Return> binding that invokes the focused button.
* Both classes gain a use_ttk parameter that selects the classic Tk or the
themed ttk widgets. It controls the widget set and the appearance that the
two procedures style differently, but not the keyboard behaviour.
* Update _place_window with the Tk 9.1 placement refinements.
* The new helpers _temp_grab_focus (a modal grab/focus context manager),
_underline_ampersand and _find_alt_key_target (ports of the Tk
accelerator-key procedures) can be reused by other tkinter dialogs, as
_setup_dialog already is.
* Fix several defects uncovered while comparing with the Tcl sources.
* Improve the simpledialog demo.
Co-authored-by: Claude Opus 4.8 <[email protected]>
This was referenced Sep 17, 2026
serhiy-storchaka
added a commit
that referenced
this pull request
Sep 29, 2026
… holds the grab (GH-157677)
_temp_grab_focus() used grab_current() and focus_get(), which raise
KeyError for windows which were not created by tkinter, such as a
native message box. Use Tcl window names instead of widgets.
Regression from GH-151848, not present in released versions.
|
Tcl/Tk was upgrade from 9.0 to 9.1 on GitHub Action, and test_idle and test_tkinter started to fail with _tkinter.TclError: invalid command name "::tk::unsupported::MacWindowStyle" on macOS CI: issue gh-159517. I created PR gh-159518, extracted from this PR, to make a minimum change to repair the CI.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
AA-Turner
Awaiting requested review from AA-Turner
AA-Turner is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|