Skip to content

gh-100617: Add a timeout parameter to tkinter wait_window()#152620

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-100617-wait-window-timeout
Open

gh-100617: Add a timeout parameter to tkinter wait_window()#152620
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-100617-wait-window-timeout

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Misc.wait_window() wraps the Tcl tkwait window command, which blocks until the window is destroyed.
It can hang indefinitely — for example on macOS when an after_idle() callback is scheduled before any window is shown (gh-100617).

Add an optional keyword-only timeout argument (in seconds).
With a timeout the wait is reimplemented in Python on top of tkapp.dooneevent(), polling winfo_exists(): it returns True once the window is destroyed, or False if the timeout elapsed first.
Without a timeout the behaviour is unchanged (the native tkwait call, always returns True).

Without a timeout wait_window() blocks until the widget is destroyed,
which can hang indefinitely.  The new keyword-only timeout parameter bounds
the wait and returns whether the widget was destroyed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33359417 | 📁 Comparing a3b734a against main (c5043dc)

  🔍 Preview build  

3 files changed
± library/tkinter.html
± whatsnew/3.16.html
± whatsnew/changelog.html

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant