diff options
author | Ned Deily <nad@acm.org> | 2014-04-20 02:14:29 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2014-04-20 02:14:29 (GMT) |
commit | 3ff96eb1e4aff841d33e9ccbe9f4278b8786ca84 (patch) | |
tree | d3d92f64460caf23b27236443891676fd4d49286 /Lib | |
parent | 5e526bba596cb14262b633c727fa2fc4a07bbfe3 (diff) | |
download | cpython-3ff96eb1e4aff841d33e9ccbe9f4278b8786ca84.zip cpython-3ff96eb1e4aff841d33e9ccbe9f4278b8786ca84.tar.gz cpython-3ff96eb1e4aff841d33e9ccbe9f4278b8786ca84.tar.bz2 |
Issue #10291: Cleanup turtledemo to use docstrings for help.
(Original patch by Alexander Belopolsky, refreshed by Jessica McKellar.)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/turtledemo/__init__.py | 14 | ||||
-rwxr-xr-x | Lib/turtledemo/__main__.py | 80 | ||||
-rw-r--r-- | Lib/turtledemo/about_turtle.txt | 76 | ||||
-rw-r--r-- | Lib/turtledemo/about_turtledemo.txt | 13 | ||||
-rw-r--r-- | Lib/turtledemo/demohelp.txt | 70 |
5 files changed, 87 insertions, 166 deletions
diff --git a/Lib/turtledemo/__init__.py b/Lib/turtledemo/__init__.py index e69de29..77150e2 100644 --- a/Lib/turtledemo/__init__.py +++ b/Lib/turtledemo/__init__.py @@ -0,0 +1,14 @@ +""" + -------------------------------------- + About this viewer + -------------------------------------- + + Tiny demo viewer to view turtle graphics example scripts. + + Quickly and dirtyly assembled by Gregor Lingl. + June, 2006 + + For more information see: turtledemo - Help + + Have fun! +""" diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index a14684c..958c283 100755 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -1,12 +1,81 @@ #!/usr/bin/env python3 + +""" + ---------------------------------------------- + + turtledemo - Help + + ---------------------------------------------- + + This document has two sections: + + (1) How to use the demo viewer + (2) How to add your own demos to the demo repository + + + (1) How to use the demo viewer. + + Select a demoscript from the example menu. + The (syntax coloured) source code appears in the left + source code window. IT CANNOT BE EDITED, but ONLY VIEWED! + + - Press START button to start the demo. + - Stop execution by pressing the STOP button. + - Clear screen by pressing the CLEAR button. + - Restart by pressing the START button again. + + SPECIAL demos are those which run EVENTDRIVEN. + (For example clock.py - or oldTurtleDemo.py which + in the end expects a mouse click.): + + Press START button to start the demo. + + - Until the EVENTLOOP is entered everything works + as in an ordinary demo script. + + - When the EVENTLOOP is entered, you control the + application by using the mouse and/or keys (or it's + controlled by some timer events) + To stop it you can and must press the STOP button. + + While the EVENTLOOP is running, the examples menu is disabled. + + - Only after having pressed the STOP button, you may + restart it or choose another example script. + + * * * * * * * * + In some rare situations there may occur interferences/conflicts + between events concerning the demo script and those concerning the + demo-viewer. (They run in the same process.) Strange behaviour may be + the consequence and in the worst case you must close and restart the + viewer. + * * * * * * * * + + + (2) How to add your own demos to the demo repository + + - place: 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.) + + !! For programs, which are EVENT DRIVEN, main must return + !! the string "EVENTLOOP". This informs the viewer, that the + !! script is still running and must be stopped by the user! +""" import sys import os from tkinter import * from idlelib.Percolator import Percolator from idlelib.ColorDelegator import ColorDelegator -from idlelib.textView import view_file # TextViewer +from idlelib.textView import view_text # TextViewer from importlib import reload +from turtledemo import __doc__ as about_turtledemo import turtle import time @@ -28,16 +97,13 @@ def getExampleEntries(): entry.endswith(".py") and entry[0] != '_'] def showDemoHelp(): - view_file(demo.root, "Help on turtleDemo", - os.path.join(demo_dir, "demohelp.txt")) + view_text(demo.root, "Help on turtledemo", __doc__) def showAboutDemo(): - view_file(demo.root, "About turtleDemo", - os.path.join(demo_dir, "about_turtledemo.txt")) + view_text(demo.root, "About turtledemo", about_turtledemo) def showAboutTurtle(): - view_file(demo.root, "About the new turtle module.", - os.path.join(demo_dir, "about_turtle.txt")) + view_text(demo.root, "About the turtle module.", turtle.__doc__) class DemoWindow(object): diff --git a/Lib/turtledemo/about_turtle.txt b/Lib/turtledemo/about_turtle.txt deleted file mode 100644 index d02c7b3..0000000 --- a/Lib/turtledemo/about_turtle.txt +++ /dev/null @@ -1,76 +0,0 @@ - -======================================================== - A new turtle module for Python -======================================================== - -Turtle graphics is a popular way for introducing programming to -kids. It was part of the original Logo programming language developed -by Wally Feurzig and Seymour Papert in 1966. - -Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it -the command turtle.forward(15), and it moves (on-screen!) 15 pixels in -the direction it is facing, drawing a line as it moves. Give it the -command turtle.right(25), and it rotates in-place 25 degrees clockwise. - -By combining together these and similar commands, intricate shapes and -pictures can easily be drawn. - ------ turtle.py - -This module is an extended reimplementation of turtle.py from the -Python standard distribution up to Python 2.5. (See: http:\\www.python.org) - -It tries to keep the merits of turtle.py and to be (nearly) 100% -compatible with it. This means in the first place to enable the -learning programmer to use all the commands, classes and methods -interactively when using the module from within IDLE run with -the -n switch. - -Roughly it has the following features added: - -- Better animation of the turtle movements, especially of turning the - turtle. So the turtles can more easily be used as a visual feedback - instrument by the (beginning) programmer. - -- Different turtle shapes, gif-images as turtle shapes, user defined - and user controllable turtle shapes, among them compound - (multicolored) shapes. Turtle shapes can be stgretched and tilted, which - makes turtles zu very versatile geometrical objects. - -- Fine control over turtle movement and screen updates via delay(), - and enhanced tracer() and speed() methods. - -- Aliases for the most commonly used commands, like fd for forward etc., - following the early Logo traditions. This reduces the boring work of - typing long sequences of commands, which often occur in a natural way - when kids try to program fancy pictures on their first encounter with - turtle graphcis. - -- Turtles now have an undo()-method with configurable undo-buffer. - -- Some simple commands/methods for creating event driven programs - (mouse-, key-, timer-events). Especially useful for programming games. - -- A scrollable Canvas class. The default scrollable Canvas can be - extended interactively as needed while playing around with the turtle(s). - -- A TurtleScreen class with methods controlling background color or - background image, window and canvas size and other properties of the - TurtleScreen. - -- There is a method, setworldcoordinates(), to install a user defined - coordinate-system for the TurtleScreen. - -- The implementation uses a 2-vector class named Vec2D, derived from tuple. - This class is public, so it can be imported by the application programmer, - which makes certain types of computations very natural and compact. - -- Appearance of the TurtleScreen and the Turtles at startup/import can be - configured by means of a turtle.cfg configuration file. - The default configuration mimics the appearance of the old turtle module. - -- If configured appropriately the module reads in docstrings from a docstring - dictionary in some different language, supplied separately and replaces - the english ones by those read in. There is a utility function - write_docstringdict() to write a dictionary with the original (english) - docstrings to disc, so it can serve as a template for translations. diff --git a/Lib/turtledemo/about_turtledemo.txt b/Lib/turtledemo/about_turtledemo.txt deleted file mode 100644 index a9009bd..0000000 --- a/Lib/turtledemo/about_turtledemo.txt +++ /dev/null @@ -1,13 +0,0 @@ - - -------------------------------------- - About this viewer - -------------------------------------- - - Tiny demo viewer to view turtle graphics example scripts. - - Quickly and dirtyly assembled by Gregor Lingl. - June, 2006 - - For more information see: turtleDemo - Help - - Have fun! diff --git a/Lib/turtledemo/demohelp.txt b/Lib/turtledemo/demohelp.txt deleted file mode 100644 index fe83bc7..0000000 --- a/Lib/turtledemo/demohelp.txt +++ /dev/null @@ -1,70 +0,0 @@ - - - ---------------------------------------------- - - turtleDemo - Help - - ---------------------------------------------- - - This document has two sections: - - (1) How to use the demo viewer - (2) How to add your own demos to the demo repository - - - (1) How to use the demo viewer. - - Select a demoscript from the example menu. - The (syntax coloured) source code appears in the left - source code window. IT CANNOT BE EDITED, but ONLY VIEWED! - - - Press START button to start the demo. - - Stop execution by pressing the STOP button. - - Clear screen by pressing the CLEAR button. - - Restart by pressing the START button again. - - SPECIAL demos are those which run EVENTDRIVEN. - (For example clock.py - or oldTurtleDemo.py which - in the end expects a mouse click.): - - Press START button to start the demo. - - - Until the EVENTLOOP is entered everything works - as in an ordinary demo script. - - - When the EVENTLOOP is entered, you control the - application by using the mouse and/or keys (or it's - controlled by some timer events) - To stop it you can and must press the STOP button. - - While the EVENTLOOP is running, the examples menu is disabled. - - - Only after having pressed the STOP button, you may - restart it or choose another example script. - - * * * * * * * * - In some rare situations there may occur interferences/conflicts - between events concerning the demo script and those concerning the - demo-viewer. (They run in the same process.) Strange behaviour may be - the consequence and in the worst case you must close and restart the - viewer. - * * * * * * * * - - - (2) How to add your own demos to the demo repository - - - place: 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.) - - !! For programs, which are EVENT DRIVEN, main must return - !! the string "EVENTLOOP". This informs the viewer, that the - !! script is still running and must be stopped by the user! - - - |