Skip to content

Commit 152dfd1

Browse files
committed
Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X.
1 parent 7c8b89e commit 152dfd1

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/turtle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,8 +997,9 @@ def __init__(self, cv, mode=_CFG["mode"],
997997
# Force Turtle window to the front on OS X. This is needed because
998998
# the Turtle window will show behind the Terminal window when you
999999
# start the demo from the command line.
1000-
cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '1')
1001-
cv._rootwindow.call('wm', 'attributes', '.', '-topmost', '0')
1000+
rootwindow = cv.winfo_toplevel()
1001+
rootwindow.call('wm', 'attributes', '.', '-topmost', '1')
1002+
rootwindow.call('wm', 'attributes', '.', '-topmost', '0')
10021003

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

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Core and Builtins
3232
Library
3333
-------
3434

35+
- Issue #22168: Prevent turtle AttributeError with non-default Canvas on OS X.
36+
3537
- Issue #21147: sqlite3 now raises an exception if the request contains a null
3638
character instead of truncate it. Based on patch by Victor Stinner.
3739

0 commit comments

Comments
 (0)