diff --git a/Lib/turtle.py b/Lib/turtle.py --- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -114,6 +114,7 @@ from os.path import isfile, split, join from copy import deepcopy from tkinter import simpledialog +import sys _tg_classes = ['ScrolledCanvas', 'TurtleScreen', 'Screen', 'RawTurtle', 'Turtle', 'RawPen', 'Pen', 'Shape', 'Vec2D'] @@ -994,6 +995,13 @@ self._keys = [] self.clear() + if sys.platform == 'darwin': + # Force Turtle window to the front on OSX. This is needed + # because the Turtle window will show behind the Terminal + # window when you show the turtle window from the command-line. + cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '1') + cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '0') + def clear(self): """Delete all drawings and all turtles from the TurtleScreen.