# HG changeset patch # Parent 8dea55fb20e99d1d76328701af175c431b2c3d70 Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X. diff -r 8dea55fb20e9 Lib/turtle.py --- a/Lib/turtle.py Sat Aug 23 18:29:02 2014 -0400 +++ b/Lib/turtle.py Sat Aug 23 17:35:04 2014 -0700 @@ -997,8 +997,9 @@ # Force Turtle window to the front on OS X. This is needed because # the Turtle window will show behind the Terminal window when you # start the demo from the command line. - cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '1') - cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '0') + rootwindow = cv.winfo_toplevel() + rootwindow.call('wm', 'attributes', '.', '-topmost', '1') + rootwindow.call('wm', 'attributes', '.', '-topmost', '0') def clear(self): """Delete all drawings and all turtles from the TurtleScreen.