GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-59396: Modernize tkinter.simpledialog by serhiy-storchaka · Pull Request #151848 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 21, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.
  • Issue: tkinter convenience dialogs don't use themed widgets #59396

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka @claude
pythongh-59396: Modernize tkinter.simpledialog
758cdca
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]>
@serhiy-storchaka
serhiy-storchaka requested a review from AA-Turner as a code owner June 21, 2026 14:19
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 21, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jun 21, 2026
tkinter convenience dialogs don't use themed widgets #59396
Closed
@read-the-docs-community

read-the-docs-community Bot commented Jun 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33265136 | 📁 Comparing ec079f6 against main (082ac30)

  🔍 Preview build  

10 files changed · ± 10 modified

± Modified

  • deprecations/index.html
  • extending/extending.html
  • library/codecs.html
  • library/dialog.html
  • library/runpy.html
  • library/tkinter.html
  • library/tkinter.ttk.html
  • library/venv.html
  • whatsnew/3.16.html
  • whatsnew/changelog.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka requested a review from terryjreedy June 21, 2026 14:38
@serhiy-storchaka
Reorder tests.
3a8c808
@serhiy-storchaka serhiy-storchaka mentioned this pull request Jun 21, 2026
gh-151678: Add tests for tkinter.simpledialog #151856
Merged
serhiy-storchaka and others added 4 commits June 21, 2026 19:28
@serhiy-storchaka @claude
Strengthen the test_background test.
530eec3
Co-Authored-By: Claude Opus 4.8 <[email protected]>
@serhiy-storchaka
Merge remote-tracking branch 'upstream/main' into tkinter-simpledialog
14dbb05
# Conflicts:
#	Doc/library/dialog.rst
#	Lib/test/test_tkinter/test_simpledialog.py
@serhiy-storchaka @claude
Improve the simpledialog demo.
2a0ad97
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]>
@serhiy-storchaka
Merge remote-tracking branch 'upstream/main' into tkinter-simpledialog
ec079f6
# Conflicts:
#	Doc/whatsnew/3.16.rst
@serhiy-storchaka
serhiy-storchaka merged commit ad38cf8 into python:main Jun 23, 2026
51 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Jun 23, 2026
@serhiy-storchaka
serhiy-storchaka deleted the tkinter-simpledialog branch June 23, 2026 08:01
This was referenced Jun 23, 2026
gh-59396: Use themed widgets in tkinter.filedialog #152036
Merged
Increase test coverage for tkinter.simpledialog #144106
Closed
@terryjreedy

terryjreedy commented Jun 29, 2026

Copy link
Copy Markdown
Member

Thanks for doing this; IDLE has a few uses. Not much change on Windows but much better on macOS.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka serhiy-storchaka mentioned this pull request Jul 5, 2026
gh-59396: Add use_ttk parameter to tkinter ScrolledText #153119
Merged
pyctrl pushed a commit to pyctrl/cpython that referenced this pull request Jul 5, 2026
@serhiy-storchaka @claude @pyctrl
pythongh-59396: Modernize tkinter.simpledialog (pythonGH-151848)
1ad2af1
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
tkinter.simpledialog: KeyError when a dialog is opened while a window not created by tkinter holds the grab #157676
Closed
gh-157676: Fix KeyError in tkinter.simpledialog when a foreign window holds the grab #157677
Merged
serhiy-storchaka added a commit that referenced this pull request Sep 29, 2026
@serhiy-storchaka
gh-157676: Fix KeyError in tkinter.simpledialog when a foreign window…
3736342
… 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.
@vstinner

vstinner commented Oct 16, 2026

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@terryjreedy terryjreedy Awaiting requested review from terryjreedy

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@serhiy-storchaka @terryjreedy @vstinner
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.