MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / shape

Method shape

Python/Turtle.py:2652–2677  ·  view source on GitHub ↗

Set turtle shape to shape with given name / return current shapename. Optional argument: name -- a string, which is a valid shapename Set turtle shape to shape with given name or, if name is not given, return name of current shape. Shape with name must exist

(self, name=None)

Source from the content-addressed store, hash-verified

2650 return q
2651
2652 def shape(self, name=None):
2653 """Set turtle shape to shape with given name / return current shapename.
2654
2655 Optional argument:
2656 name -- a string, which is a valid shapename
2657
2658 Set turtle shape to shape with given name or, if name is not given,
2659 return name of current shape.
2660 Shape with name must exist in the TurtleScreen's shape dictionary.
2661 Initially there are the following polygon shapes:
2662 'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'.
2663 To learn about how to deal with shapes see Screen-method register_shape.
2664
2665 Example (for a Turtle instance named turtle):
2666 >>> turtle.shape()
2667 'arrow'
2668 >>> turtle.shape("turtle")
2669 >>> turtle.shape()
2670 'turtle'
2671 """
2672 if name is None:
2673 return self.turtle.shapeIndex
2674 if not name in self.screen.getshapes():
2675 raise TurtleGraphicsError("There is no shape named %s" % name)
2676 self.turtle._setshape(name)
2677 self._update()
2678
2679 def shapesize(self, stretch_wid=None, stretch_len=None, outline=None):
2680 """Set/return turtle's stretchfactors/outline. Set resizemode to "user".

Callers 2

pong.pyFile · 0.80
demo2Function · 0.80

Calls 4

_updateMethod · 0.95
TurtleGraphicsErrorClass · 0.85
getshapesMethod · 0.80
_setshapeMethod · 0.80

Tested by

no test coverage detected