Skip to content

Use tkinter wrapper methods instead of raw Tcl calls in turtle and IDLE#152414

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-stdlib-use-wrappers
Jun 30, 2026
Merged

Use tkinter wrapper methods instead of raw Tcl calls in turtle and IDLE#152414
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-stdlib-use-wrappers

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 27, 2026

Copy link
Copy Markdown
Member

Replace explicit tk.call() invocations in turtle and idlelib with the equivalent higher-level tkinter wrapper methods. No behavior change.

  • turtle: rootwindow.wm_attributes(topmost=...) instead of call('wm', 'attributes', '.', '-topmost', ...), using the keyword form of wm_attributes() (added in wm_attributes doesn't take keyword arguments #43457).
  • idlelib.macosx._init_tk_type(): root.winfo_server() instead of root.tk.call('winfo', 'server', '.').
  • idlelib tests: after_info() instead of tk.call('after', 'info').

@terryjreedy

Copy link
Copy Markdown
Member

I was thinking about asking you if any of the tk calls could be updated. Are the 2 new root.x wrapper methods in IDLE in main only or at least in 3.15, so an IDLE backport can be done?

Either way, I think that merging this now and dealing with a possible but very unlikely future backport merge conflict is better than waiting a couple of years until these changes can be backported completely.

There are about 20 'after' 'info' calls in tests that can be replaced by after_info and backported to 3.13. I will do these separately. Did you check whether any of the other ~20 other calls replaced here now have wrappers?

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

tk_scaling is 3.15, wm_attributes -- 3.13, winfo_server -- always. after_info -- 3.13. I can add after_info here.

@terryjreedy

Copy link
Copy Markdown
Member

Emscripten build and test failed. The [Explain error] AI 'failed', with no explanation. Since the AI apparently replaced the ability to manually scan the test log, I just reran.

@terryjreedy

Copy link
Copy Markdown
Member

I presume you made changes with Opus. Can it undo 3.x changes for backport to 3.x?? For each file in the diff, [...] on the right expands to view, edit, or delete file, but not revert file.

* turtle: wm_attributes(topmost=...);
* idlelib.macosx: winfo_server();
* idlelib tests: after_info().

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Split out to #152465. I force-pushed to create a single simple commit message.

@terryjreedy

Copy link
Copy Markdown
Member

Do you want me to merge and tend to backports, or are you still thinking about these 2 PRs?

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

I only wait for your approve, because it is just cosmetic change.

@terryjreedy

Copy link
Copy Markdown
Member

In the winfo server and wm attributes replacements, I don't know what the original '.' arg was, but assume you do and correctly omitted it in the the replacement.

I otherwise approve of the IDLE changes and would like them backported. I don't care about the turtle change either way.

@serhiy-storchaka serhiy-storchaka merged commit fc866dc into python:main Jun 30, 2026
51 of 52 checks passed
@serhiy-storchaka serhiy-storchaka deleted the tkinter-stdlib-use-wrappers branch June 30, 2026 05:41
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 30, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker fc866dc84ec430ab22d60609520f7ab27267baef 3.14

@serhiy-storchaka serhiy-storchaka added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 30, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker fc866dc84ec430ab22d60609520f7ab27267baef 3.13

@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

GH-152648 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 30, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member Author

In the winfo server and wm attributes replacements, I don't know what the original '.' arg was

It was the path to the toplevel widget (the root in that case). In methods it is inferred from self.

serhiy-storchaka added a commit that referenced this pull request Jun 30, 2026
… and IDLE (GH-152414) (GH-152648)

Use tkinter wrapper methods instead of raw Tcl calls in turtle and IDLE (GH-152414)

* turtle: wm_attributes(topmost=...);
* idlelib.macosx: winfo_server();
* idlelib tests: after_info().
(cherry picked from commit fc866dc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
stestagg pushed a commit to stestagg/cpython that referenced this pull request Jun 30, 2026
…LE (pythonGH-152414)

* turtle: wm_attributes(topmost=...);
* idlelib.macosx: winfo_server();
* idlelib tests: after_info().

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@bedevere-app

bedevere-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

GH-152662 is a backport of this pull request to the 3.14 branch.

@bedevere-app

bedevere-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

GH-152663 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 30, 2026
serhiy-storchaka added a commit that referenced this pull request Jun 30, 2026
… and IDLE (GH-152414) (GH-152662)

* turtle: wm_attributes(topmost=...);
* idlelib.macosx: winfo_server();
* idlelib tests: after_info().
(cherry picked from commit fc866dc)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 30, 2026
… and IDLE (GH-152414) (GH-152663)

* turtle: wm_attributes(topmost=...);
* idlelib.macosx: winfo_server();
* idlelib tests: after_info().
(cherry picked from commit fc866dc)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@terryjreedy

Copy link
Copy Markdown
Member

Backports merged, thank you.

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.

2 participants