Skip to content

Commit c5a72e6

Browse files
committed
Issue #14117: Inprove help text and docstrings, some for clarity, some just to
fit in the default width of the text window (45 chars).
1 parent 6f6922c commit c5a72e6

File tree

7 files changed

+60
-48
lines changed

7 files changed

+60
-48
lines changed

Lib/turtledemo/demohelp.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,28 @@
5353

5454
(2) How to add your own demos to the demo repository
5555

56-
- place: same directory as turtledemo/__main__.py
56+
- Place the file in the same directory as turtledemo/__main__.py
5757

58-
- requirements on source code:
59-
code must contain a main() function which will
60-
be executed by the viewer (see provided example scripts)
61-
main() may return a string which will be displayed
62-
in the Label below the source code window (when execution
63-
has finished.)
58+
- The code must contain a main() function which will
59+
be executed by the viewer (see provided example scripts).
60+
It may return a string which will be displayed in the Label below
61+
the source code window (when execution has finished.)
6462

65-
If the demo is EVENT DRIVEN, main must return the string
66-
"EVENTLOOP". This informs the demo viewer that the script is
67-
still running and must be stopped by the user!
63+
- In order to run mydemo.py by itself, such as during development,
64+
add the following at the end of the file:
6865

69-
If an "EVENTLOOP" demo runs by itself, as with clock, which uses
70-
ontimer, or minimal_hanoi, which loops by recursion, then the
71-
code should catch the turtle.Terminator exception that will be
72-
raised when the user presses the STOP button. (Paint is not such
73-
a demo; it only acts in response to mouse clicks and movements.)
66+
if __name__ == '__main__':
67+
main()
68+
mainloop() # keep window
7469

70+
python -m turtledemo.mydemo # will then run it
71+
72+
- If the demo is EVENT DRIVEN, main must return the string
73+
"EVENTLOOP". This informs the demo viewer that the script is
74+
still running and must be stopped by the user!
75+
76+
If an "EVENTLOOP" demo runs by itself, as with clock, which uses
77+
ontimer, or minimal_hanoi, which loops by recursion, then the
78+
code should catch the turtle.Terminator exception that will be
79+
raised when the user presses the STOP button. (Paint is not such
80+
a demo; it only acts in response to mouse clicks and movements.)

Lib/turtledemo/forest.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
44
tdemo_forest.py
55
6-
Displays a 'forest' of 3 'breadth-first-trees'
7-
similar to the one from example tree.
8-
For further remarks see xtx_tree.py
6+
Displays a 'forest' of 3 breadth-first-trees
7+
similar to the one in tree.
8+
For further remarks see tree.py
99
1010
This example is a 'breadth-first'-rewrite of
11-
a Logo program written by Erich Neuwirth. See:
11+
a Logo program written by Erich Neuwirth. See
1212
http://homepage.univie.ac.at/erich.neuwirth/
1313
"""
1414
from turtle import Turtle, colormode, tracer, mainloop
@@ -104,6 +104,5 @@ def main():
104104
return "runtime: %.2f sec." % (b-a)
105105

106106
if __name__ == '__main__':
107-
msg = main()
108-
print(msg)
107+
main()
109108
mainloop()

Lib/turtledemo/paint.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
44
tdemo_paint.py
55
6-
A simple eventdriven paint program
6+
A simple event-driven paint program
77
8-
- use left mouse button to move turtle
9-
- middle mouse button to change color
10-
- right mouse button do turn filling on/off
8+
- left mouse button moves turtle
9+
- middle mouse button changes color
10+
- right mouse button toogles betweem pen up
11+
(no line drawn when the turtle moves) and
12+
pen down (line is drawn). If pen up follows
13+
at least two pen-down moves, the polygon that
14+
includes the starting point is filled.
1115
-------------------------------------------
1216
Play around by clicking into the canvas
1317
using all three mouse buttons.

Lib/turtledemo/peace.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
44
tdemo_peace.py
55
6-
A very simple drawing suitable as a beginner's
7-
programming example.
8-
9-
Uses only commands, which are also available in
10-
old turtle.py.
11-
12-
Intentionally no variables are used except for the
13-
colorloop:
6+
A simple drawing suitable as a beginner's
7+
programming example. Aside from the
8+
peacecolors assignment and the for loop,
9+
it only uses turtle commands.
1410
"""
1511

1612
from turtle import *
@@ -21,7 +17,7 @@ def main():
2117
"royalblue1", "dodgerblue4")
2218

2319
reset()
24-
s = Screen()
20+
Screen()
2521
up()
2622
goto(-320,-195)
2723
width(70)
@@ -58,7 +54,7 @@ def main():
5854
up()
5955

6056
goto(0,300) # vanish if hideturtle() is not available ;-)
61-
return "Done!!"
57+
return "Done!"
6258

6359
if __name__ == "__main__":
6460
main()

Lib/turtledemo/planet_and_moon.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
Planet has a circular orbit, moon a stable
1313
orbit around the planet.
1414
15-
You can hold the movement temporarily by pressing
16-
the left mouse button with mouse over the
17-
scrollbar of the canvas.
15+
You can hold the movement temporarily by
16+
pressing the left mouse button with the
17+
mouse over the scrollbar of the canvas.
1818
1919
"""
2020
from turtle import Shape, Turtle, mainloop, Vec2D as Vec
@@ -108,6 +108,5 @@ def main():
108108
return "Done!"
109109

110110
if __name__ == '__main__':
111-
msg = main()
112-
print(msg)
113-
#mainloop()
111+
main()
112+
mainloop()

Lib/turtledemo/tree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
(1) a tree-generator, where the drawing is
1212
quasi the side-effect, whereas the generator
1313
always yields None.
14-
(2) Turtle-cloning: At each branching point the
15-
current pen is cloned. So in the end there
16-
are 1024 turtles.
14+
(2) Turtle-cloning: At each branching point
15+
the current pen is cloned. So in the end
16+
there are 1024 turtles.
1717
"""
1818
from turtle import Turtle, mainloop
1919
from time import clock

Lib/turtledemo/two_canvases.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
#!/usr/bin/env python3
2-
## DEMONSTRATES USE OF 2 CANVASES, SO CANNOT BE RUN IN DEMOVIEWER!
3-
"""turtle example: Using TurtleScreen and RawTurtle
4-
for drawing on two distinct canvases.
1+
"""turtledemo.two_canvases
2+
3+
Use TurtleScreen and RawTurtle to draw on two
4+
distinct canvases.
55
"""
6+
#The final mainloop only serves to keep the window open.
7+
8+
#TODO: This runs in its own two-canvas window when selected in the
9+
#demoviewer examples menu but the text is not loaded and the previous
10+
#example is left visible. If the ending mainloop is removed, the text
11+
#Eis loaded, this run again in a third window, and if start is pressed,
12+
#demoviewer raises an error because main is not found, and then freezes.
13+
614
from turtle import TurtleScreen, RawTurtle, TK
715

816
root = TK.Tk()

0 commit comments

Comments
 (0)