MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / TurtleScreen

Class TurtleScreen

tools/python-3.11.9-amd64/Lib/turtle.py:956–1509  ·  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

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