gh-59396: Modernize tkinter.simpledialog#151848
Open
serhiy-storchaka wants to merge 5 commits into
Open
Conversation
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 <noreply@anthropic.com>
Documentation build overview
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# 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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This reworks
tkinter.simpledialogto match the look and feel of the native Tk dialogs:SimpleDialogis a port of::tk_dialog, andDialogis a base class whose button box is modelled on::tk::MessageBox.SimpleDialog,askinteger,askfloatandaskstringnow use the themedtkinter.ttkwidgets by default; theDialogbase class still defaults to the classic widgets for compatibility. Both classes gained a keyword-onlyuse_ttkparameter to select the widget set.Alt+ the underlined letter), a default ring that follows the keyboard focus, and<Return>that invokes the focused button.SimpleDialoggainedbitmapanddetailparameters, draws the standard icons with themed images in the ttk version, and accepts mappings of button options asbuttonsentries._temp_grab_focus,_underline_ampersandand_find_alt_key_targetcan be reused by other tkinter dialogs, as_setup_dialogalready is.