Skip to content

[3.15] gh-154357: Fix tkinter, ttk and IDLE tests depending on the window manager (GH-154370) - #157063

Merged
hugovk merged 2 commits into
python:3.15from
serhiy-storchaka:backport-3b56438-3.15
Oct 3, 2026
Merged

hugovk merged 2 commits into
python:3.15from
serhiy-storchaka:backport-3b56438-3.15

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Manual backport of GH-154370: the cherry-pick does not apply, because this branch does not have all the tests which the original commit changes. The changes to test_wm_stackorder are omitted -- there is no such test on this branch.

The window manager can take the focus from the application, ignore lift() and resize a toplevel on its own. Tk delivers generated keyboard events to the window which has the focus, so a test which lost the focus does not get the event at all.

  • Hide the root window in the dialog tests, so that it does not compete for the focus.
  • Take the focus right before generating a key event.
  • Tolerate additional focus events.
  • Do not check focus_get() and focus_displayof() without the focus.
  • Resize the toplevel to fit its content in wait_until_mapped().
…the window manager (pythonGH-154370)

The window manager can take the focus from the application, ignore
lift() and resize a toplevel on its own.

* Hide the root window in the dialog tests, so that it does not compete
  for the focus.
* Take the focus right before generating a key event.
* Tolerate additional focus events.
* Do not check focus_get() and focus_displayof() without the focus.
* Resize the toplevel to fit its content in wait_until_mapped().

(cherry picked from commit 3b56438)
SimpleDialog makes its window transient for the master unconditionally on
this branch, and a transient of a hidden window is never mapped on
Windows, so that go() blocks in wait_visibility().
@hugovk
hugovk merged commit e5ea201 into python:3.15 Oct 3, 2026
51 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the backport-3b56438-3.15 branch November 25, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants