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

Method pen

Lib/turtle.py:2420–2543  ·  view source on GitHub ↗

Return or set the pen's attributes. Arguments: pen -- a dictionary with some or all of the below listed keys. **pendict -- one or more keyword-arguments with the below listed keys as keywords. Return or set the pen's attributes in a

(self, pen=None, **pendict)

Source from the content-addressed store, hash-verified

2418 return self._shown
2419
2420 def pen(self, pen=None, **pendict):
2421 """Return or set the pen's attributes.
2422
2423 Arguments:
2424 pen -- a dictionary with some or all of the below listed keys.
2425 **pendict -- one or more keyword-arguments with the below
2426 listed keys as keywords.
2427
2428 Return or set the pen's attributes in a 'pen-dictionary'
2429 with the following key/value pairs:
2430 "shown" : True/False
2431 "pendown" : True/False
2432 "pencolor" : color-string or color-tuple
2433 "fillcolor" : color-string or color-tuple
2434 "pensize" : positive number
2435 "speed" : number in range 0..10
2436 "resizemode" : "auto" or "user" or "noresize"
2437 "stretchfactor": (positive number, positive number)
2438 "shearfactor": number
2439 "outline" : positive number
2440 "tilt" : number
2441
2442 This dictionary can be used as argument for a subsequent
2443 pen()-call to restore the former pen-state. Moreover one
2444 or more of these attributes can be provided as keyword-arguments.
2445 This can be used to set several pen attributes in one statement.
2446
2447
2448 Examples (for a Turtle instance named turtle):
2449 >>> turtle.pen(fillcolor="black", pencolor="red", pensize=10)
2450 >>> turtle.pen()
2451 {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
2452 'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',
2453 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
2454 >>> penstate=turtle.pen()
2455 >>> turtle.color("yellow","")
2456 >>> turtle.penup()
2457 >>> turtle.pen()
2458 {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
2459 'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',
2460 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
2461 >>> p.pen(penstate, fillcolor="green")
2462 >>> p.pen()
2463 {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
2464 'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',
2465 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
2466 """
2467 _pd = {"shown" : self._shown,
2468 "pendown" : self._drawing,
2469 "pencolor" : self._pencolor,
2470 "fillcolor" : self._fillcolor,
2471 "pensize" : self._pensize,
2472 "speed" : self._speed,
2473 "resizemode" : self._resizemode,
2474 "stretchfactor" : self._stretchfactor,
2475 "shearfactor" : self._shearfactor,
2476 "outline" : self._outlinewidth,
2477 "tilt" : self._tilt

Callers 15

resizemodeMethod · 0.95
pensizeMethod · 0.95
penupMethod · 0.95
pendownMethod · 0.95
speedMethod · 0.95
colorMethod · 0.95
pencolorMethod · 0.95
fillcolorMethod · 0.95
teleportMethod · 0.95
showturtleMethod · 0.95
hideturtleMethod · 0.95
teleportMethod · 0.80

Calls 5

_colorstrMethod · 0.95
_newLineMethod · 0.95
_updateMethod · 0.95
updateMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected