Skip to content

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

Merged
serhiy-storchaka merged 2 commits into
python:3.13from
serhiy-storchaka:backport-3b56438-3.13
Sep 7, 2026
Merged

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

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().
@serhiy-storchaka
serhiy-storchaka merged commit fa7835f into python:3.13 Sep 7, 2026
41 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the backport-3b56438-3.13 branch September 7, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant