Skip to content

Commit 06ee0ea

Browse files
gh-154357: Fix flaky wait_until_mapped(full_size=True)
After a test which left the root window without content, the window manager can resize it to its minimum size. Tk then remembers that size as if it were set by "wm geometry" and no longer resizes the toplevel to fit the content of the following test.
1 parent 76301d0 commit 06ee0ea

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/test/test_tkinter/support.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def wait_until_mapped(widget, timeout=None, *, full_size=False):
122122
timeout = support.LOOPBACK_TIMEOUT
123123
deadline = time.monotonic() + timeout
124124
widget.update_idletasks()
125+
reset = False
125126
while True:
126127
widget.update() # drain pending Map/Configure events
127128
if widget.winfo_ismapped():
@@ -133,6 +134,11 @@ def wait_until_mapped(widget, timeout=None, *, full_size=False):
133134
h_ok = widget.winfo_height() > 1
134135
if w_ok and h_ok:
135136
return True
137+
if full_size and not reset:
138+
# Tk no longer resizes the toplevel to fit its content if
139+
# the window manager has resized it. Undo this.
140+
widget.winfo_toplevel().wm_geometry('')
141+
reset = True
136142
if time.monotonic() >= deadline:
137143
return False
138144
time.sleep(0.01)

0 commit comments

Comments
 (0)