10000 bpo-43534: Fix the turtle module working with multiple root windows G… · python/cpython@b47f051 · GitHub
[go: up one dir, main page]

Skip to content

Commit b47f051

Browse files
bpo-43534: Fix the turtle module working with multiple root windows GH-25593
(cherry picked from commit 8af929f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 2b475dc commit b47f051

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Lib/turtle.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,18 @@ class TurtleScreenBase(object):
464464
a corresponding TurtleScreenBase class has to be implemented.
465465
"""
466466

467-
@staticmethod
468-
def _blankimage():
467+
def _blankimage(self):
469468
"""return a blank image object
470469
"""
471-
img = TK.PhotoImage(width=1, height=1)
470+
img = TK.PhotoImage(width=1, height=1, master=self.cv)
472471
img.blank()
473472
return img
474473

475-
@staticmethod
476-
def _image(filename):
474+
def _image(self, filename):
477475
"""return an image object containing the
478476
imagedata from a gif-file named filename.
479477
"""
480-
return TK.PhotoImage(file=filename)
478+
return TK.PhotoImage(file=filename, master=self.cv)
481479

482480
def __init__(self, cv):
483481
self.cv = cv
@@ -811,7 +809,7 @@ def mainloop(self):
811809
>>> screen.mainloop()
812810
813811
"""
814-
TK.mainloop()
812+
self.cv.tk.mainloop()
815813

816814
def textinput(self, title, prompt):
817815
"""Pop up a dialog window for input of a string.
@@ -966,6 +964,8 @@ class TurtleScreen(TurtleScreenBase):
966964

967965
def __init__(self, cv, mode=_CFG["mode"],
968966
colormode=_CFG["colormode"], delay=_CFG["delay"]):
967+
TurtleScreenBase.__init__(self, cv)
968+
969969
self._shapes = {
970970
"arrow" : Shape("polygon", ((-10,0), (10,0), (0,10))),
971971
"turtle" : Shape("polygon", ((0,16), (-2,14), (-1,10), (-4,7),
@@ -989,7 +989,6 @@ def __init__(self, cv, mode=_CFG["mode"],
989989

990990
self._bgpics = {"nopic" : ""}
991991

992-
TurtleScreenBase.__init__(self, cv)
993992
self._mode = mode
994993
self._delayvalue = delay
995994
self._colormode = _CFG["colormode"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the :mod:`turtle` module working with non-default root window.

0 commit comments

Comments
 (0)
0