diff -r eba85ae7d128 Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Sun Apr 12 00:26:43 2015 -0400 +++ b/Lib/idlelib/PyShell.py Sun Apr 12 18:52:31 2015 -0400 @@ -1398,6 +1398,21 @@ def close(self): self.shell.close() +def set_icon_to_idle_icon(toplevel_widget): + # Given the toplevel widget (as returned by Tk()), sets the window's + # icon to the IDLE icon. + icondir = os.path.join(os.path.dirname(__file__), 'Icons') + if system() == 'Windows': + # Windows uses the idle.ico file for the icon. + iconfile = os.path.join(icondir, 'idle.ico') + toplevel_widget.wm_iconbitmap(default=iconfile) + elif TkVersion >= 8.5: + # Non-Windows uses the .png or .gif file for the icon. + ext = '.png' if TkVersion >= 8.6 else '.gif' + iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext)) + for size in (16, 32, 48)] + icons = [PhotoImage(file=iconfile) for iconfile in iconfiles] + toplevel_widget.wm_iconphoto(True, *icons) usage_msg = """\ @@ -1535,16 +1550,7 @@ root = Tk(className="Idle") # set application icon - icondir = os.path.join(os.path.dirname(__file__), 'Icons') - if system() == 'Windows': - iconfile = os.path.join(icondir, 'idle.ico') - root.wm_iconbitmap(default=iconfile) - elif TkVersion >= 8.5: - ext = '.png' if TkVersion >= 8.6 else '.gif' - iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext)) - for size in (16, 32, 48)] - icons = [PhotoImage(file=iconfile) for iconfile in iconfiles] - root.wm_iconphoto(True, *icons) + set_icon_to_idle_icon(root) fixwordbreaks(root) root.withdraw() diff -r eba85ae7d128 Lib/turtle.py --- a/Lib/turtle.py Sun Apr 12 00:26:43 2015 -0400 +++ b/Lib/turtle.py Sun Apr 12 18:52:31 2015 -0400 @@ -114,6 +114,7 @@ from os.path import isfile, split, join from copy import deepcopy from tkinter import simpledialog +from idlelib import PyShell _tg_classes = ['ScrolledCanvas', 'TurtleScreen', 'Screen', 'RawTurtle', 'Turtle', 'RawPen', 'Pen', 'Shape', 'Vec2D'] @@ -433,6 +434,8 @@ def __init__(self): TK.Tk.__init__(self) + PyShell.set_icon_to_idle_icon(self) + def setupcanvas(self, width, height, cwidth, cheight): self._canvas = ScrolledCanvas(self, width, height, cwidth, cheight) self._canvas.pack(expand=1, fill="both") diff -r eba85ae7d128 Lib/turtledemo/__main__.py --- a/Lib/turtledemo/__main__.py Sun Apr 12 00:26:43 2015 -0400 +++ b/Lib/turtledemo/__main__.py Sun Apr 12 18:52:31 2015 -0400 @@ -92,6 +92,7 @@ from idlelib.Percolator import Percolator from idlelib.ColorDelegator import ColorDelegator from idlelib.textView import view_text +from idlelib import PyShell from turtledemo import __doc__ as about_turtledemo import turtle @@ -131,6 +132,9 @@ root.title('Python turtle-graphics examples') root.wm_protocol("WM_DELETE_WINDOW", self._destroy) + import pdb; pdb.set_trace() + PyShell.set_icon_to_idle_icon(root) + if darwin: import subprocess # Make sure we are the currently activated OS X application