This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Turtle Graphics RawTurtle problem
Type: Stage: resolved
Components: Tkinter Versions: Python 3.4, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ned.deily Nosy List: Kent.D..Lee, ned.deily
Priority: normal Keywords: patch

Created on 2014-08-08 01:27 by Kent.D..Lee, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit Kent.D..Lee, 2014-08-08 01:27
issue22168.patch ned.deily, 2014-08-24 00:47 review
Messages (5)
msg225049 - (view) Author: Kent D. Lee (Kent.D..Lee) Date: 2014-08-08 01:27
This is either a turtle graphics or tkinter problem. 

In Python 3.4 it appears that something in Turtle Graphics broke or at least changed. I get the following error when trying to run a program that works in Python 3.1 and 3.2.

Kent's Mac> python3.4
Traceback (most recent call last):
  File "", line 283, in <module>
  File "", line 277, in main
    animApp = Connect4Application(root)
  File "", line 110, in __init__
  File "", line 129, in buildWindow
    theTurtle = turtle.RawTurtle(canvas)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/", line 2534, in __init__
    self.screen = TurtleScreen(canvas)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/", line 1000, in __init__'wm', 'attributes', '.', '-topmost', '1')
AttributeError: 'Canvas' object has no attribute '_rootwindow'
Kent's Mac> 

The code is attached. The error occurs on line 129 when trying to create a RawTurtle and provide it with a Canvas.
msg225053 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-08-08 02:57
It looks like the changes associated with Issue11571, released in 3.4.1, cause this problem when the program supplies its own Canvas object rather than relying on the turtle module to create a default one.
msg225054 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-08-08 03:02
As a temporary workaround, you could edit to revert that change, in other words, just search for and delete the whole "if sys.platform == 'darwin'" test:

diff -r d85fcf23549e Lib/
--- a/Lib/     Tue Aug 05 14:02:11 2014 -0500
+++ b/Lib/     Thu Aug 07 19:58:25 2014 -0700
@@ -993,12 +993,6 @@
         self._colormode = _CFG["colormode"]
         self._keys = []
-        if sys.platform == 'darwin':
-            # 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.
-  'wm', 'attributes', '.', '-topmost', '1')
-  'wm', 'attributes', '.', '-topmost', '0')

     def clear(self):
         """Delete all drawings and all turtles from the TurtleScreen.

The file is at /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
msg225776 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-08-24 00:47
The attached patch should prevent the AttributeError exception when not using a default Canvas.  I now think the overall approach introduced in Issue11571 is not the best.  I plan to commit this fix for now but encourage more robust solutions in the long term.
msg226863 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-09-14 07:05
The changesets below should prevent the problem in 3.4.2 and 3.5.0.  Since there are no standard tests for turtle at the moment, there is no testcase for using a non-default Canvas but one should be added when turtle tests are (Issue21914 and Issue21916). 

New changset fac17d06e01d by Ned Deily in branch '3.4':
Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X.

New changeset 775453a7b85d by Ned Deily in branch 'default':
Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X.
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66364
2014-09-14 07:05:33ned.deilysetstatus: open -> closed
resolution: fixed
messages: + msg226863

stage: patch review -> resolved
2014-08-24 00:47:02ned.deilysetfiles: + issue22168.patch
keywords: + patch
messages: + msg225776

stage: needs patch -> patch review
2014-08-08 03:02:42ned.deilysetmessages: + msg225054
2014-08-08 02:57:02ned.deilysetversions: + Python 3.5
nosy: + ned.deily

messages: + msg225053

assignee: ned.deily
stage: needs patch
2014-08-08 01:27:43Kent.D..Leecreate