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

Method pen

Python/Turtle.py:2235–2358  ·  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

2233 return self._shown
2234
2235 def pen(self, pen=None, **pendict):
2236 """Return or set the pen's attributes.
2237
2238 Arguments:
2239 pen -- a dictionary with some or all of the below listed keys.
2240 **pendict -- one or more keyword-arguments with the below
2241 listed keys as keywords.
2242
2243 Return or set the pen's attributes in a 'pen-dictionary'
2244 with the following key/value pairs:
2245 "shown" : True/False
2246 "pendown" : True/False
2247 "pencolor" : color-string or color-tuple
2248 "fillcolor" : color-string or color-tuple
2249 "pensize" : positive number
2250 "speed" : number in range 0..10
2251 "resizemode" : "auto" or "user" or "noresize"
2252 "stretchfactor": (positive number, positive number)
2253 "shearfactor": number
2254 "outline" : positive number
2255 "tilt" : number
2256
2257 This dictionary can be used as argument for a subsequent
2258 pen()-call to restore the former pen-state. Moreover one
2259 or more of these attributes can be provided as keyword-arguments.
2260 This can be used to set several pen attributes in one statement.
2261
2262
2263 Examples (for a Turtle instance named turtle):
2264 >>> turtle.pen(fillcolor="black", pencolor="red", pensize=10)
2265 >>> turtle.pen()
2266 {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
2267 'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',
2268 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
2269 >>> penstate=turtle.pen()
2270 >>> turtle.color("yellow","")
2271 >>> turtle.penup()
2272 >>> turtle.pen()
2273 {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
2274 'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',
2275 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
2276 >>> p.pen(penstate, fillcolor="green")
2277 >>> p.pen()
2278 {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
2279 'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',
2280 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
2281 """
2282 _pd = {"shown" : self._shown,
2283 "pendown" : self._drawing,
2284 "pencolor" : self._pencolor,
2285 "fillcolor" : self._fillcolor,
2286 "pensize" : self._pensize,
2287 "speed" : self._speed,
2288 "resizemode" : self._resizemode,
2289 "stretchfactor" : self._stretchfactor,
2290 "shearfactor" : self._shearfactor,
2291 "outline" : self._outlinewidth,
2292 "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
showturtleMethod · 0.95
hideturtleMethod · 0.95
shapesizeMethod · 0.80
shearfactorMethod · 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