| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -904,7 +904,7 @@ def addcomponent(self, poly, fill, outline=None): | |||
| 904 | 904 | >>> poly = ((0,0),(10,-5),(0,10),(-10,-5)) | |
| 905 | 905 | >>> s = Shape("compound") | |
| 906 | 906 | >>> s.addcomponent(poly, "red", "blue") | |
| 907 | - ### .. add more components and then use register_shape() | ||
| 907 | + >>> # .. add more components and then use register_shape() | ||
| 908 | 908 | """ | |
| 909 | 909 | if self._type != "compound": | |
| 910 | 910 | raise TurtleGraphicsError("Cannot add component to %s Shape" | |
@@ -1002,7 +1002,7 @@ def clear(self): | |||
| 1002 | 1002 | no backgroundimage, no eventbindings and tracing on. | |
| 1003 | 1003 | ||
| 1004 | 1004 | Example (for a TurtleScreen instance named screen): | |
| 1005 | - screen.clear() | ||
| 1005 | + >>> screen.clear() | ||
| 1006 | 1006 | ||
| 1007 | 1007 | Note: this method is not available as function. | |
| 1008 | 1008 | """ | |
@@ -1076,8 +1076,8 @@ def setworldcoordinates(self, llx, lly, urx, ury): | |||
| 1076 | 1076 | Example (for a TurtleScreen instance named screen): | |
| 1077 | 1077 | >>> screen.setworldcoordinates(-10,-0.5,50,1.5) | |
| 1078 | 1078 | >>> for _ in range(36): | |
| 1079 | - left(10) | ||
| 1080 | - forward(0.5) | ||
| 1079 | + ... left(10) | ||
| 1080 | + ... forward(0.5) | ||
| 1081 | 1081 | """ | |
| 1082 | 1082 | if self.mode() != "world": | |
| 1083 | 1083 | self.mode("world") | |
@@ -1181,7 +1181,7 @@ def colormode(self, cmode=None): | |||
| 1181 | 1181 | >>> screen.colormode() | |
| 1182 | 1182 | 1.0 | |
| 1183 | 1183 | >>> screen.colormode(255) | |
| 1184 | - >>> turtle.pencolor(240,160,80) | ||
| 1184 | + >>> pencolor(240,160,80) | ||
| 1185 | 1185 | """ | |
| 1186 | 1186 | if cmode is None: | |
| 1187 | 1187 | return self._colormode | |
@@ -1249,9 +1249,9 @@ def tracer(self, n=None, delay=None): | |||
| 1249 | 1249 | >>> screen.tracer(8, 25) | |
| 1250 | 1250 | >>> dist = 2 | |
| 1251 | 1251 | >>> for i in range(200): | |
| 1252 | - fd(dist) | ||
| 1253 | - rt(90) | ||
| 1254 | - dist += 2 | ||
| 1252 | + ... fd(dist) | ||
| 1253 | + ... rt(90) | ||
| 1254 | + ... dist += 2 | ||
| 1255 | 1255 | """ | |
| 1256 | 1256 | if n is None: | |
| 1257 | 1257 | return self._tracing | |
@@ -1278,7 +1278,7 @@ def delay(self, delay=None): | |||
| 1278 | 1278 | self._delayvalue = int(delay) | |
| 1279 | 1279 | ||
| 1280 | 1280 | def _incrementudc(self): | |
| 1281 | - "Increment upadate counter.""" | ||
| 1281 | + """Increment upadate counter.""" | ||
| 1282 | 1282 | if not TurtleScreen._RUNNING: | |
| 1283 | 1283 | TurtleScreen._RUNNNING = True | |
| 1284 | 1284 | raise Terminator | |
@@ -1346,16 +1346,12 @@ def onclick(self, fun, btn=1, add=None): | |||
| 1346 | 1346 | clicked point on the canvas. | |
| 1347 | 1347 | num -- the number of the mouse-button, defaults to 1 | |
| 1348 | 1348 | ||
| 1349 | - Example (for a TurtleScreen instance named screen | ||
| 1350 | - and a Turtle instance named turtle): | ||
| 1349 | + Example (for a TurtleScreen instance named screen) | ||
| 1351 | 1350 | ||
| 1352 | - >>> screen.onclick(turtle.goto) | ||
| 1353 | - | ||
| 1354 | - ### Subsequently clicking into the TurtleScreen will | ||
| 1355 | - ### make the turtle move to the clicked point. | ||
| 1351 | + >>> screen.onclick(goto) | ||
| 1352 | + >>> # Subsequently clicking into the TurtleScreen will | ||
| 1353 | + >>> # make the turtle move to the clicked point. | ||
| 1356 | 1354 | >>> screen.onclick(None) | |
| 1357 | - | ||
| 1358 | - ### event-binding will be removed | ||
| 1359 | 1355 | """ | |
| 1360 | 1356 | self._onscreenclick(fun, btn, add) | |
| 1361 | 1357 | ||
@@ -1369,20 +1365,18 @@ def onkey(self, fun, key): | |||
| 1369 | 1365 | In order to be able to register key-events, TurtleScreen | |
| 1370 | 1366 | must have focus. (See method listen.) | |
| 1371 | 1367 | ||
| 1372 | - Example (for a TurtleScreen instance named screen | ||
| 1373 | - and a Turtle instance named turtle): | ||
| 1368 | + Example (for a TurtleScreen instance named screen): | ||
| 1374 | 1369 | ||
| 1375 | 1370 | >>> def f(): | |
| 1376 | - fd(50) | ||
| 1377 | - lt(60) | ||
| 1378 | - | ||
| 1379 | - | ||
| 1371 | + ... fd(50) | ||
| 1372 | + ... lt(60) | ||
| 1373 | + ... | ||
| 1380 | 1374 | >>> screen.onkey(f, "Up") | |
| 1381 | 1375 | >>> screen.listen() | |
| 1382 | 1376 | ||
| 1383 | - ### Subsequently the turtle can be moved by | ||
| 1384 | - ### repeatedly pressing the up-arrow key, | ||
| 1385 | - ### consequently drawing a hexagon | ||
| 1377 | + Subsequently the turtle can be moved by repeatedly pressing | ||
| 1378 | + the up-arrow key, consequently drawing a hexagon | ||
| 1379 | + | ||
| 1386 | 1380 | """ | |
| 1387 | 1381 | if fun is None: | |
| 1388 | 1382 | if key in self._keys: | |
@@ -1406,16 +1400,15 @@ def onkeypress(self, fun, key=None): | |||
| 1406 | 1400 | and a Turtle instance named turtle): | |
| 1407 | 1401 | ||
| 1408 | 1402 | >>> def f(): | |
| 1409 | - fd(50) | ||
| 1410 | - | ||
| 1411 | - | ||
| 1412 | - >>> screen.onkey(f, "Up") | ||
| 1403 | + ... fd(50) | ||
| 1404 | + ... lt(60) | ||
| 1405 | + ... | ||
| 1406 | + >>> screen.onkeypress(f, "Up") | ||
| 1413 | 1407 | >>> screen.listen() | |
| 1414 | 1408 | ||
| 1415 | - ### Subsequently the turtle can be moved by | ||
| 1416 | - ### repeatedly pressing the up-arrow key, | ||
| 1417 | - ### or by keeping pressed the up-arrow key. | ||
| 1418 | - ### consequently drawing a hexagon. | ||
| 1409 | + Subsequently the turtle can be moved by repeatedly pressing | ||
| 1410 | + the up-arrow key, or by keeping pressed the up-arrow key. | ||
| 1411 | + consequently drawing a hexagon. | ||
| 1419 | 1412 | """ | |
| 1420 | 1413 | if fun is None: | |
| 1421 | 1414 | if key in self._keys: | |
@@ -1447,12 +1440,12 @@ def ontimer(self, fun, t=0): | |||
| 1447 | 1440 | ||
| 1448 | 1441 | >>> running = True | |
| 1449 | 1442 | >>> def f(): | |
| 1450 | - if running: | ||
| 1451 | - fd(50) | ||
| 1452 | - lt(60) | ||
| 1453 | - screen.ontimer(f, 250) | ||
| 1454 | - | ||
| 1455 | - >>> f() ### makes the turtle marching around | ||
| 1443 | + ... if running: | ||
| 1444 | + ... fd(50) | ||
| 1445 | + ... lt(60) | ||
| 1446 | + ... screen.ontimer(f, 250) | ||
| 1447 | + ... | ||
| 1448 | + >>> f() # makes the turtle marching around | ||
| 1456 | 1449 | >>> running = False | |
| 1457 | 1450 | """ | |
| 1458 | 1451 | self._ontimer(fun, t) | |
@@ -1496,7 +1489,7 @@ def screensize(self, canvwidth=None, canvheight=None, bg=None): | |||
| 1496 | 1489 | ||
| 1497 | 1490 | Example (for a Turtle instance named turtle): | |
| 1498 | 1491 | >>> turtle.screensize(2000,1500) | |
| 1499 | - ### e. g. to search for an erroneously escaped turtle ;-) | ||
| 1492 | + >>> # e.g. to search for an erroneously escaped turtle ;-) | ||
| 1500 | 1493 | """ | |
| 1501 | 1494 | return self._resize(canvwidth, canvheight, bg) | |
| 1502 | 1495 | ||
@@ -2084,7 +2077,7 @@ def pensize(self, width=None): | |||
| 2084 | 2077 | Example (for a Turtle instance named turtle): | |
| 2085 | 2078 | >>> turtle.pensize() | |
| 2086 | 2079 | 1 | |
| 2087 | - turtle.pensize(10) # from here on lines of width 10 are drawn | ||
| 2080 | + >>> turtle.pensize(10) # from here on lines of width 10 are drawn | ||
| 2088 | 2081 | """ | |
| 2089 | 2082 | if width is None: | |
| 2090 | 2083 | return self._pensize | |
@@ -2559,7 +2552,7 @@ def reset(self): | |||
| 2559 | 2552 | """Delete the turtle's drawings and restore its default values. | |
| 2560 | 2553 | ||
| 2561 | 2554 | No argument. | |
| 2562 | - , | ||
| 2555 | + | ||
| 2563 | 2556 | Delete the turtle's drawings from the screen, re-center the turtle | |
| 2564 | 2557 | and set variables to the default values. | |
| 2565 | 2558 | ||
@@ -2606,7 +2599,7 @@ def undobufferentries(self): | |||
| 2606 | 2599 | ||
| 2607 | 2600 | Example (for a Turtle instance named turtle): | |
| 2608 | 2601 | >>> while undobufferentries(): | |
| 2609 | - undo() | ||
| 2602 | + ... undo() | ||
| 2610 | 2603 | """ | |
| 2611 | 2604 | if self.undobuffer is None: | |
| 2612 | 2605 | return 0 | |
@@ -2682,9 +2675,9 @@ def _tracer(self, flag=None, delay=None): | |||
| 2682 | 2675 | >>> turtle.tracer(8, 25) | |
| 2683 | 2676 | >>> dist = 2 | |
| 2684 | 2677 | >>> for i in range(200): | |
| 2685 | - turtle.fd(dist) | ||
| 2686 | - turtle.rt(90) | ||
| 2687 | - dist += 2 | ||
| 2678 | + ... turtle.fd(dist) | ||
| 2679 | + ... turtle.rt(90) | ||
| 2680 | + ... dist += 2 | ||
| 2688 | 2681 | """ | |
| 2689 | 2682 | return self.screen.tracer(flag, delay) | |
| 2690 | 2683 | ||
@@ -2882,7 +2875,6 @@ def tiltangle(self, angle=None): | |||
| 2882 | 2875 | >>> turtle.shapesize(5,2) | |
| 2883 | 2876 | >>> turtle.tilt(45) | |
| 2884 | 2877 | >>> turtle.tiltangle() | |
| 2885 | - >>> | ||
| 2886 | 2878 | """ | |
| 2887 | 2879 | if angle is None: | |
| 2888 | 2880 | tilt = -self._tilt * (180.0/math.pi) * self._angleOrient | |
@@ -2927,7 +2919,7 @@ def shapetransform(self, t11=None, t12=None, t21=None, t22=None): | |||
| 2927 | 2919 | >>> turtle.shapesize(4,2) | |
| 2928 | 2920 | >>> turtle.shearfactor(-0.5) | |
| 2929 | 2921 | >>> turtle.shapetransform() | |
| 2930 | - >>> (4.0, -1.0, -0.0, 2.0) | ||
| 2922 | + (4.0, -1.0, -0.0, 2.0) | ||
| 2931 | 2923 | """ | |
| 2932 | 2924 | if t11 is t12 is t21 is t22 is None: | |
| 2933 | 2925 | return self._shapetrafo | |
@@ -3125,7 +3117,7 @@ def clearstamps(self, n=None): | |||
| 3125 | 3117 | ||
| 3126 | 3118 | Example (for a Turtle instance named turtle): | |
| 3127 | 3119 | >>> for i in range(8): | |
| 3128 | - turtle.stamp(); turtle.fd(30) | ||
| 3120 | + ... turtle.stamp(); turtle.fd(30) | ||
| 3129 | 3121 | ... | |
| 3130 | 3122 | >>> turtle.clearstamps(2) | |
| 3131 | 3123 | >>> turtle.clearstamps(-2) | |
@@ -3301,9 +3293,9 @@ def filling(self): | |||
| 3301 | 3293 | Example (for a Turtle instance named turtle): | |
| 3302 | 3294 | >>> turtle.begin_fill() | |
| 3303 | 3295 | >>> if turtle.filling(): | |
| 3304 | - turtle.pensize(5) | ||
| 3305 | - else: | ||
| 3306 | - turtle.pensize(3) | ||
| 3296 | + ... turtle.pensize(5) | ||
| 3297 | + ... else: | ||
| 3298 | + ... turtle.pensize(3) | ||
| 3307 | 3299 | """ | |
| 3308 | 3300 | return isinstance(self._fillpath, list) | |
| 3309 | 3301 | ||
@@ -3533,9 +3525,9 @@ def onclick(self, fun, btn=1, add=None): | |||
| 3533 | 3525 | Example for the anonymous turtle, i. e. the procedural way: | |
| 3534 | 3526 | ||
| 3535 | 3527 | >>> def turn(x, y): | |
| 3536 | - left(360) | ||
| 3537 | - | ||
| 3538 | - >>> onclick(turn) # Now clicking into the turtle will turn it. | ||
| 3528 | + ... left(360) | ||
| 3529 | + ... | ||
| 3530 | + >>> onclick(turn) # Now clicking into the turtle will turn it. | ||
| 3539 | 3531 | >>> onclick(None) # event-binding will be removed | |
| 3540 | 3532 | """ | |
| 3541 | 3533 | self.screen._onclick(self.turtle._item, fun, btn, add) | |
@@ -3551,16 +3543,17 @@ def onrelease(self, fun, btn=1, add=None): | |||
| 3551 | 3543 | ||
| 3552 | 3544 | Example (for a MyTurtle instance named joe): | |
| 3553 | 3545 | >>> class MyTurtle(Turtle): | |
| 3554 | - def glow(self,x,y): | ||
| 3555 | - self.fillcolor("red") | ||
| 3556 | - def unglow(self,x,y): | ||
| 3557 | - self.fillcolor("") | ||
| 3558 | - | ||
| 3546 | + ... def glow(self,x,y): | ||
| 3547 | + ... self.fillcolor("red") | ||
| 3548 | + ... def unglow(self,x,y): | ||
| 3549 | + ... self.fillcolor("") | ||
| 3550 | + ... | ||
| 3559 | 3551 | >>> joe = MyTurtle() | |
| 3560 | 3552 | >>> joe.onclick(joe.glow) | |
| 3561 | 3553 | >>> joe.onrelease(joe.unglow) | |
| 3562 | - ### clicking on joe turns fillcolor red, | ||
| 3563 | - ### unclicking turns it to transparent. | ||
| 3554 | + | ||
| 3555 | + Clicking on joe turns fillcolor red, unclicking turns it to | ||
| 3556 | + transparent. | ||
| 3564 | 3557 | """ | |
| 3565 | 3558 | self.screen._onrelease(self.turtle._item, fun, btn, add) | |
| 3566 | 3559 | self._update() | |
@@ -3579,9 +3572,9 @@ def ondrag(self, fun, btn=1, add=None): | |||
| 3579 | 3572 | Example (for a Turtle instance named turtle): | |
| 3580 | 3573 | >>> turtle.ondrag(turtle.goto) | |
| 3581 | 3574 | ||
| 3582 | - ### Subsequently clicking and dragging a Turtle will | ||
| 3583 | - ### move it across the screen thereby producing handdrawings | ||
| 3584 | - ### (if pen is down). | ||
| 3575 | + Subsequently clicking and dragging a Turtle will move it | ||
| 3576 | + across the screen thereby producing handdrawings (if pen is | ||
| 3577 | + down). | ||
| 3585 | 3578 | """ | |
| 3586 | 3579 | self.screen._ondrag(self.turtle._item, fun, btn, add) | |
| 3587 | 3580 | ||
@@ -3629,10 +3622,11 @@ def undo(self): | |||
| 3629 | 3622 | ||
| 3630 | 3623 | Example (for a Turtle instance named turtle): | |
| 3631 | 3624 | >>> for i in range(4): | |
| 3632 | - turtle.fd(50); turtle.lt(80) | ||
| 3633 | - | ||
| 3625 | + ... turtle.fd(50); turtle.lt(80) | ||
| 3626 | + ... | ||
| 3634 | 3627 | >>> for i in range(8): | |
| 3635 | - turtle.undo() | ||
| 3628 | + ... turtle.undo() | ||
| 3629 | + ... | ||
| 3636 | 3630 | """ | |
| 3637 | 3631 | if self.undobuffer is None: | |
| 3638 | 3632 | return | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -399,6 +399,8 @@ Core and Builtins | |||
| 399 | 399 | Library | |
| 400 | 400 | ------- | |
| 401 | 401 | ||
| 402 | + - Issue #13439: Fix many errors in turtle docstrings. | ||
| 403 | + | ||
| 402 | 404 | - Issue #6715: Add a module 'lzma' for compression using the LZMA algorithm. | |
| 403 | 405 | Thanks to Per Øyvind Karlsen for the initial implementation. | |
| 404 | 406 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments