diff options
Diffstat (limited to 'Lib/turtledemo/demohelp.txt')
-rw-r--r-- | Lib/turtledemo/demohelp.txt | 36 |
1 files changed, 21 insertions, 15 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.) |