aboutsummaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-06-24 22:21:36 -0400
committerTerry Jan Reedy <tjreedy@udel.edu>2014-06-24 22:21:36 -0400
commit3fecd48bded335cf79851a23c66fd8e8195f9516 (patch)
tree813bfe85e60b4737b52d670116596b2f0253d914 /Demo
parent53296810f8db94bc138184b302413607f65f4262 (diff)
downloadplatform_external_python_cpython2-3fecd48bded335cf79851a23c66fd8e8195f9516.tar.gz
platform_external_python_cpython2-3fecd48bded335cf79851a23c66fd8e8195f9516.tar.bz2
platform_external_python_cpython2-3fecd48bded335cf79851a23c66fd8e8195f9516.zip
Issue #14117: Inprove help text and docstrings, some for clarity, some just to
fit in the default width of the text window (45 chars).
Diffstat (limited to 'Demo')
-rw-r--r--Demo/turtle/demohelp.txt48
-rwxr-xr-xDemo/turtle/tdemo_paint.py12
-rwxr-xr-xDemo/turtle/tdemo_peace.py16
-rwxr-xr-xDemo/turtle/tdemo_planet_and_moon.py9
-rwxr-xr-xDemo/turtle/tdemo_tree.py6
5 files changed, 46 insertions, 45 deletions
diff --git a/Demo/turtle/demohelp.txt b/Demo/turtle/demohelp.txt
index 9517493a46..d364e94e8f 100644
--- a/Demo/turtle/demohelp.txt
+++ b/Demo/turtle/demohelp.txt
@@ -2,7 +2,7 @@
----------------------------------------------
- xturtleDemo - Help
+ turtleDemo - Help
----------------------------------------------
@@ -53,27 +53,29 @@
(2) How to add your own demos to the demo repository
- - scriptname: must begin with tdemo_ ,
+ - The script name must begin with tdemo_ ,
so it must have the form tdemo_<your-script-name>.py
- - place: same directory as xturtleDemo.py or some
- subdirectory, the name of which must also begin with
- tdemo_.....
-
- - 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.)
-
- 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.)
-
+ - 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.)
+
+ - In order to run mydemo.py by itself, such as during development,
+ add the following at the end of the file:
+
+ 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/Demo/turtle/tdemo_paint.py b/Demo/turtle/tdemo_paint.py
index e1d63030f6..105a06b611 100755
--- a/Demo/turtle/tdemo_paint.py
+++ b/Demo/turtle/tdemo_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/Demo/turtle/tdemo_peace.py b/Demo/turtle/tdemo_peace.py
index 13044c986d..8bfa92022f 100755
--- a/Demo/turtle/tdemo_peace.py
+++ b/Demo/turtle/tdemo_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/Demo/turtle/tdemo_planet_and_moon.py b/Demo/turtle/tdemo_planet_and_moon.py
index 223d87b4cd..a0280d7acc 100755
--- a/Demo/turtle/tdemo_planet_and_moon.py
+++ b/Demo/turtle/tdemo_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
+ main()
mainloop()
diff --git a/Demo/turtle/tdemo_tree.py b/Demo/turtle/tdemo_tree.py
index 6fc87359af..6c6121ad95 100755
--- a/Demo/turtle/tdemo_tree.py
+++ b/Demo/turtle/tdemo_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