[Python-checkins] bpo-43534: Fix the turtle module working with multiple root windows GH-25594
orsenthil
webhook-mailer at python.org
Sun Apr 25 21:54:29 EDT 2021
https://github.com/python/cpython/commit/9ca20fdc4c27e31832adbd6d393a87e7d8953e3c
commit: 9ca20fdc4c27e31832adbd6d393a87e7d8953e3c
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: orsenthil <skumaran at gatech.edu>
date: 2021-04-25T18:54:25-07:00
summary:
bpo-43534: Fix the turtle module working with multiple root windows GH-25594
(cherry picked from commit 8af929fc76f21fb123f6a47cb3ebcf4e5b758dea)
Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
files:
A Misc/NEWS.d/next/Library/2021-04-25-13-34-13.bpo-43937.isx95l.rst
M Lib/turtle.py
diff --git a/Lib/turtle.py b/Lib/turtle.py
index 13f662a8c2108..024fed858f683 100644
--- a/Lib/turtle.py
+++ b/Lib/turtle.py
@@ -464,20 +464,18 @@ class TurtleScreenBase(object):
a corresponding TurtleScreenBase class has to be implemented.
"""
- @staticmethod
- def _blankimage():
+ def _blankimage(self):
"""return a blank image object
"""
- img = TK.PhotoImage(width=1, height=1)
+ img = TK.PhotoImage(width=1, height=1, master=self.cv)
img.blank()
return img
- @staticmethod
- def _image(filename):
+ def _image(self, filename):
"""return an image object containing the
imagedata from a gif-file named filename.
"""
- return TK.PhotoImage(file=filename)
+ return TK.PhotoImage(file=filename, master=self.cv)
def __init__(self, cv):
self.cv = cv
@@ -811,7 +809,7 @@ def mainloop(self):
>>> screen.mainloop()
"""
- TK.mainloop()
+ self.cv.tk.mainloop()
def textinput(self, title, prompt):
"""Pop up a dialog window for input of a string.
@@ -966,6 +964,8 @@ class TurtleScreen(TurtleScreenBase):
def __init__(self, cv, mode=_CFG["mode"],
colormode=_CFG["colormode"], delay=_CFG["delay"]):
+ TurtleScreenBase.__init__(self, cv)
+
self._shapes = {
"arrow" : Shape("polygon", ((-10,0), (10,0), (0,10))),
"turtle" : Shape("polygon", ((0,16), (-2,14), (-1,10), (-4,7),
@@ -989,7 +989,6 @@ def __init__(self, cv, mode=_CFG["mode"],
self._bgpics = {"nopic" : ""}
- TurtleScreenBase.__init__(self, cv)
self._mode = mode
self._delayvalue = delay
self._colormode = _CFG["colormode"]
diff --git a/Misc/NEWS.d/next/Library/2021-04-25-13-34-13.bpo-43937.isx95l.rst b/Misc/NEWS.d/next/Library/2021-04-25-13-34-13.bpo-43937.isx95l.rst
new file mode 100644
index 0000000000000..cb4d90b723d1f
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-04-25-13-34-13.bpo-43937.isx95l.rst
@@ -0,0 +1 @@
+Fixed the :mod:`turtle` module working with non-default root window.
More information about the Python-checkins
mailing list