Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/idlelib/iomenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ def encode(self, chars):
return chars.encode('utf-8-sig')

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.

self.old_print(event)

def old_print(self, event):
confirm = messagebox.askokcancel(
title="Print",
message="Print to Default Printer",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use tk text print when running tk 9.0+. Patch by Terry J. Reedy.
Loading