MCPcopy Index your code
hub / github.com/python/cpython / TurtleScreen

Class TurtleScreen

Lib/turtle.py:946–1569  ·  view source on GitHub ↗

Provides screen oriented methods like bgcolor etc. Only relies upon the methods of TurtleScreenBase and NOT upon components of the underlying graphics toolkit - which is Tkinter in this case.

Source from the content-addressed store, hash-verified

944
945
946class TurtleScreen(TurtleScreenBase):
947 """Provides screen oriented methods like bgcolor etc.
948
949 Only relies upon the methods of TurtleScreenBase and NOT
950 upon components of the underlying graphics toolkit -
951 which is Tkinter in this case.
952 """
953 _RUNNING = True
954
955 def __init__(self, cv, mode=_CFG["mode"],
956 colormode=_CFG["colormode"], delay=_CFG["delay"]):
957 TurtleScreenBase.__init__(self, cv)
958
959 self._shapes = {
960 "arrow" : Shape("polygon", ((-10,0), (10,0), (0,10))),
961 "turtle" : Shape("polygon", ((0,16), (-2,14), (-1,10), (-4,7),
962 (-7,9), (-9,8), (-6,5), (-7,1), (-5,-3), (-8,-6),
963 (-6,-8), (-4,-5), (0,-7), (4,-5), (6,-8), (8,-6),
964 (5,-3), (7,1), (6,5), (9,8), (7,9), (4,7), (1,10),
965 (2,14))),
966 "circle" : Shape("polygon", ((10,0), (9.51,3.09), (8.09,5.88),
967 (5.88,8.09), (3.09,9.51), (0,10), (-3.09,9.51),
968 (-5.88,8.09), (-8.09,5.88), (-9.51,3.09), (-10,0),
969 (-9.51,-3.09), (-8.09,-5.88), (-5.88,-8.09),
970 (-3.09,-9.51), (-0.00,-10.00), (3.09,-9.51),
971 (5.88,-8.09), (8.09,-5.88), (9.51,-3.09))),
972 "square" : Shape("polygon", ((10,-10), (10,10), (-10,10),
973 (-10,-10))),
974 "triangle" : Shape("polygon", ((10,-5.77), (0,11.55),
975 (-10,-5.77))),
976 "classic": Shape("polygon", ((0,0),(-5,-9),(0,-7),(5,-9))),
977 "blank" : Shape("image", self._blankimage())
978 }
979
980 self._bgpics = {"nopic" : ""}
981
982 self._mode = mode
983 self._delayvalue = delay
984 self._colormode = _CFG["colormode"]
985 self._keys = []
986 self.clear()
987 if sys.platform == 'darwin':
988 # Force Turtle window to the front on OS X. This is needed because
989 # the Turtle window will show behind the Terminal window when you
990 # start the demo from the command line.
991 rootwindow = cv.winfo_toplevel()
992 rootwindow.call('wm', 'attributes', '.', '-topmost', '1')
993 rootwindow.call('wm', 'attributes', '.', '-topmost', '0')
994
995 def clear(self):
996 """Delete all drawings and all turtles from the TurtleScreen.
997
998 No argument.
999
1000 Reset empty TurtleScreen to its initial state: white background,
1001 no backgroundimage, no eventbindings and tracing on.
1002
1003 Example (for a TurtleScreen instance named screen):

Callers 2

mainFunction · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…