diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-25 02:21:41 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-25 02:21:41 (GMT) |
commit | c5a72e6971b2927aa5fbfa6d7e02f6018b989768 (patch) | |
tree | 08fa163da474ab4f506c697e951cfe47a49771d9 | |
parent | 6f6922c0906e2986e221cb48c338f67ee72f1aee (diff) | |
download | cpython-c5a72e6971b2927aa5fbfa6d7e02f6018b989768.zip cpython-c5a72e6971b2927aa5fbfa6d7e02f6018b989768.tar.gz cpython-c5a72e6971b2927aa5fbfa6d7e02f6018b989768.tar.bz2 |
Issue #14117: Inprove help text and docstrings, some for clarity, some just to
fit in the default width of the text window (45 chars).
-rw-r--r-- | Lib/turtledemo/demohelp.txt | 36 | ||||
-rwxr-xr-x | Lib/turtledemo/forest.py | 11 | ||||
-rwxr-xr-x | Lib/turtledemo/paint.py | 12 | ||||
-rwxr-xr-x | Lib/turtledemo/peace.py | 16 | ||||
-rwxr-xr-x | Lib/turtledemo/planet_and_moon.py | 11 | ||||
-rwxr-xr-x | Lib/turtledemo/tree.py | 6 | ||||
-rwxr-xr-x | Lib/turtledemo/two_canvases.py | 16 |
7 files changed, 60 insertions, 48 deletions
diff --git a/Lib/turtledemo/demohelp.txt b/Lib/turtledemo/demohelp.txt index 96af26d..5a7f557 100644 --- a/Lib/turtledemo/demohelp.txt +++ b/Lib/turtledemo/demohelp.txt @@ -53,22 +53,28 @@ (2) How to add your own demos to the demo repository - - place: same directory as turtledemo/__main__.py + - Place the file in the same directory as turtledemo/__main__.py - - requirements on source code: - code must contain a main() function which will - be executed by the viewer (see provided example scripts) - main() may return a string which will be displayed - in the Label below the source code window (when execution - has finished.) + - The code must contain a main() function which will + be executed by the viewer (see provided example scripts). + It may return a string which will be displayed in the Label below + the source code window (when execution has finished.) - If the demo is EVENT DRIVEN, main must return the string - "EVENTLOOP". This informs the demo viewer that the script is - still running and must be stopped by the user! + - In order to run mydemo.py by itself, such as during development, + add the following at the end of the file: - If an "EVENTLOOP" demo runs by itself, as with clock, which uses - ontimer, or minimal_hanoi, which loops by recursion, then the - code should catch the turtle.Terminator exception that will be - raised when the user presses the STOP button. (Paint is not such - a demo; it only acts in response to mouse clicks and movements.) + if __name__ == '__main__': + main() + mainloop() # keep window + python -m turtledemo.mydemo # will then run it + + - If the demo is EVENT DRIVEN, main must return the string + "EVENTLOOP". This informs the demo viewer that the script is + still running and must be stopped by the user! + + If an "EVENTLOOP" demo runs by itself, as with clock, which uses + ontimer, or minimal_hanoi, which loops by recursion, then the + code should catch the turtle.Terminator exception that will be + raised when the user presses the STOP button. (Paint is not such + a demo; it only acts in response to mouse clicks and movements.) diff --git a/Lib/turtledemo/forest.py b/Lib/turtledemo/forest.py index a837d84..7fe080e 100755 --- a/Lib/turtledemo/forest.py +++ b/Lib/turtledemo/forest.py @@ -3,12 +3,12 @@ tdemo_forest.py -Displays a 'forest' of 3 'breadth-first-trees' -similar to the one from example tree. -For further remarks see xtx_tree.py +Displays a 'forest' of 3 breadth-first-trees +similar to the one in tree. +For further remarks see tree.py This example is a 'breadth-first'-rewrite of -a Logo program written by Erich Neuwirth. See: +a Logo program written by Erich Neuwirth. See http://homepage.univie.ac.at/erich.neuwirth/ """ from turtle import Turtle, colormode, tracer, mainloop @@ -104,6 +104,5 @@ def main(): return "runtime: %.2f sec." % (b-a) if __name__ == '__main__': - msg = main() - print(msg) + main() mainloop() diff --git a/Lib/turtledemo/paint.py b/Lib/turtledemo/paint.py index 68058ab..dde1691 100755 --- a/Lib/turtledemo/paint.py +++ b/Lib/turtledemo/paint.py @@ -3,11 +3,15 @@ tdemo_paint.py -A simple eventdriven paint program +A simple event-driven paint program -- use left mouse button to move turtle -- middle mouse button to change color -- right mouse button do turn filling on/off +- left mouse button moves turtle +- middle mouse button changes color +- right mouse button toogles betweem pen up +(no line drawn when the turtle moves) and +pen down (line is drawn). If pen up follows +at least two pen-down moves, the polygon that +includes the starting point is filled. ------------------------------------------- Play around by clicking into the canvas using all three mouse buttons. diff --git a/Lib/turtledemo/peace.py b/Lib/turtledemo/peace.py index 63cf7cc..e2ba928 100755 --- a/Lib/turtledemo/peace.py +++ b/Lib/turtledemo/peace.py @@ -3,14 +3,10 @@ tdemo_peace.py -A very simple drawing suitable as a beginner's -programming example. - -Uses only commands, which are also available in -old turtle.py. - -Intentionally no variables are used except for the -colorloop: +A simple drawing suitable as a beginner's +programming example. Aside from the +peacecolors assignment and the for loop, +it only uses turtle commands. """ from turtle import * @@ -21,7 +17,7 @@ def main(): "royalblue1", "dodgerblue4") reset() - s = Screen() + Screen() up() goto(-320,-195) width(70) @@ -58,7 +54,7 @@ def main(): up() goto(0,300) # vanish if hideturtle() is not available ;-) - return "Done!!" + return "Done!" if __name__ == "__main__": main() diff --git a/Lib/turtledemo/planet_and_moon.py b/Lib/turtledemo/planet_and_moon.py index 14c4bbc..26abfdb 100755 --- a/Lib/turtledemo/planet_and_moon.py +++ b/Lib/turtledemo/planet_and_moon.py @@ -12,9 +12,9 @@ very light moon! Planet has a circular orbit, moon a stable orbit around the planet. -You can hold the movement temporarily by pressing -the left mouse button with mouse over the -scrollbar of the canvas. +You can hold the movement temporarily by +pressing the left mouse button with the +mouse over the scrollbar of the canvas. """ from turtle import Shape, Turtle, mainloop, Vec2D as Vec @@ -108,6 +108,5 @@ def main(): return "Done!" if __name__ == '__main__': - msg = main() - print(msg) - #mainloop() + main() + mainloop() diff --git a/Lib/turtledemo/tree.py b/Lib/turtledemo/tree.py index 9c0b1f7..71fff35 100755 --- a/Lib/turtledemo/tree.py +++ b/Lib/turtledemo/tree.py @@ -11,9 +11,9 @@ Uses: (1) a tree-generator, where the drawing is quasi the side-effect, whereas the generator always yields None. -(2) Turtle-cloning: At each branching point the -current pen is cloned. So in the end there -are 1024 turtles. +(2) Turtle-cloning: At each branching point +the current pen is cloned. So in the end +there are 1024 turtles. """ from turtle import Turtle, mainloop from time import clock diff --git a/Lib/turtledemo/two_canvases.py b/Lib/turtledemo/two_canvases.py index 02d89db..26882ca 100755 --- a/Lib/turtledemo/two_canvases.py +++ b/Lib/turtledemo/two_canvases.py @@ -1,8 +1,16 @@ -#!/usr/bin/env python3 -## DEMONSTRATES USE OF 2 CANVASES, SO CANNOT BE RUN IN DEMOVIEWER! -"""turtle example: Using TurtleScreen and RawTurtle -for drawing on two distinct canvases. +"""turtledemo.two_canvases + +Use TurtleScreen and RawTurtle to draw on two +distinct canvases. """ +#The final mainloop only serves to keep the window open. + +#TODO: This runs in its own two-canvas window when selected in the +#demoviewer examples menu but the text is not loaded and the previous +#example is left visible. If the ending mainloop is removed, the text +#Eis loaded, this run again in a third window, and if start is pressed, +#demoviewer raises an error because main is not found, and then freezes. + from turtle import TurtleScreen, RawTurtle, TK root = TK.Tk() |