Skip to content

gh-43720: IDLE - use tk text print when available#153744

Open
terryjreedy wants to merge 2 commits into
python:mainfrom
terryjreedy:tkprint
Open

gh-43720: IDLE - use tk text print when available#153744
terryjreedy wants to merge 2 commits into
python:mainfrom
terryjreedy:tkprint

Conversation

@terryjreedy

@terryjreedy terryjreedy commented Jul 15, 2026

Copy link
Copy Markdown
Member

The new tk print command is available in tk 9.0.  When running
tk 8.6, fall back to old code.
@terryjreedy terryjreedy self-assigned this Jul 15, 2026
@terryjreedy terryjreedy added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 15, 2026
@terryjreedy terryjreedy changed the title Tkprint gh-43720: IDLE - use tk text print when available Jul 15, 2026
Comment thread Lib/idlelib/iomenu.py
def print_window(self, event):
try:
self.text.tk.call('tk', 'print', self.text)
except tkinter.TclError:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no tkinter import here.

Larger issue is that this catches all TclError; if tk print exists but fails mid-print, it will silently pop up a second dialog. I suggest to check for "unknown subcommand" in the error message, or, better, test the Tk version. Anyway, you need to handle TclError in tk_print() if they are not already handled at higher level.

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

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants