bpo-43534: Fix the turtle module working with multiple root windows GH-25593

(cherry picked from commit 8af929fc76)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-04-25 18:54:41 -07:00 committed by GitHub
parent 2b475dc1ff
commit b47f05157b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -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 @@ class TurtleScreenBase(object):
>>> 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 @@ class TurtleScreen(TurtleScreenBase):
self._bgpics = {"nopic" : ""}
TurtleScreenBase.__init__(self, cv)
self._mode = mode
self._delayvalue = delay
self._colormode = _CFG["colormode"]