1717
1818--------------
1919
20- Introduction
21- ============
22-
23- Turtle graphics is an implementation of `the popular geometric drawing tools
24- introduced in Logo <https://en.wikipedia.org/wiki/Turtle_
25- (robot)> `_, developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon
26- in 1967.
27-
28-
29- Get started
30- ===========
31-
32- Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle ``, give it the
33- command ``turtle.forward(15) ``, and it moves (on-screen!) 15 pixels in the
34- direction it is facing, drawing a line as it moves. Give it the command
35- ``turtle.right(25) ``, and it rotates in-place 25 degrees clockwise.
36-
3720.. sidebar :: Turtle star
3821
3922 Turtle can draw intricate shapes using programs that repeat simple
@@ -42,21 +25,40 @@ direction it is facing, drawing a line as it moves. Give it the command
4225 .. image :: turtle-star.*
4326 :align: center
4427
45- In Python, turtle graphics provides a representation of a physical "turtle"
46- (a little robot with a pen) that draws on a sheet of paper on the floor.
28+ Imagine a robotic turtle starting at (0, 0) in the x-y plane.
29+ After an ``import turtle ``, give it the command ``turtle.forward(15) ``, and it
30+ moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as
31+ it moves. Give it the command ``turtle.right(25) ``, and it rotates in-place 25
32+ degrees clockwise.
33+
34+ Turtle graphics is an implementation of `the drawing tools introduced in Logo
35+ <https://en.wikipedia.org/wiki/Turtle_(robot)> `_ in 1967. It was created as an
36+ educational tool, and its instant, visible feedback makes it an effective way
37+ for learners to encounter programming concepts. It is also a convenient way to
38+ produce simple graphical output without bringing in external libraries.
39+
40+ This document includes four main sections:
4741
48- It's an effective and well-proven way for learners to encounter
49- programming concepts and interaction with software, as it provides instant,
50- visible feedback. It also provides convenient access to graphical output
51- in general.
42+ * :ref: `turtle-tutorial ` teaches the basics of turtle drawing.
43+ * :ref: `turtle-reference ` describes the functions, methods and classes this
44+ module defines.
45+ * :ref: `turtle-howtos ` details how to handle specific tasks.
46+ * :ref: `turtle-explanation ` provides background on the object-oriented
47+ interface.
48+
49+ .. note ::
5250
53- Turtle drawing was originally created as an educational tool, to be used by
54- teachers in the classroom. For the programmer who needs to produce some
55- graphical output it can be a way to do that without the overhead of
56- introducing more complex or external libraries into their work.
51+ Turtle graphics requires the :mod: `tkinter ` optional module.
52+ The python.org installers for Windows and macOS include it, but some
53+ Linux distributions and other platforms may package it separately. If
54+ ``import turtle `` fails with an error mentioning ``_tkinter ``, look for
55+ documentation from your distributor (that is, whoever provided Python to you).
56+ Check this in advance if you're planning to use turtle graphics with a learner.
5757
5858
5959.. _turtle-tutorial :
60+ .. _get-started :
61+ .. _get-started-as-quickly-as-possible :
6062
6163Tutorial
6264========
@@ -99,7 +101,8 @@ Notice how the turtle, represented by an arrow, points in different
99101directions as you steer it.
100102
101103Experiment with those commands, and also with ``backward() `` and
102- ``right() ``.
104+ ``right() ``. Many commands also have terser aliases, such as ``fd() `` for
105+ :func: `forward `.
103106
104107
105108Pen control
@@ -179,38 +182,16 @@ Finally, complete the filling::
179182``end_fill() `` command.)
180183
181184
185+ .. _turtle-howtos :
182186.. _turtle-how-to :
187+ .. _how-to :
183188
184- How to...
185- =========
189+ How-to guides
190+ =============
186191
187192This section covers some typical turtle use-cases and approaches.
188193
189194
190- Get started as quickly as possible
191- ----------------------------------
192-
193- One of the joys of turtle graphics is the immediate, visual feedback that's
194- available from simple commands - it's an excellent way to introduce children
195- to programming ideas, with a minimum of overhead (not just children, of
196- course).
197-
198- The turtle module makes this possible by exposing all its basic functionality
199- as functions, available with ``from turtle import * ``. The :ref: `turtle
200- graphics tutorial <turtle-tutorial>` covers this approach.
201-
202- It's worth noting that many of the turtle commands also have even more terse
203- equivalents, such as ``fd() `` for :func: `forward `. These are especially
204- useful when working with learners for whom typing is not a skill.
205-
206- .. _note :
207-
208- You'll need to have the :mod: `Tk interface package <tkinter> ` installed on
209- your system for turtle graphics to work. Be warned that this is not
210- always straightforward, so check this in advance if you're planning to
211- use turtle graphics with a learner.
212-
213-
214195Use the ``turtle `` module namespace
215196-----------------------------------
216197
@@ -289,8 +270,11 @@ The turtle's screen can be customised, for example::
289270 t.screen.bgcolor("orange")
290271
291272
292- Turtle graphics reference
293- =========================
273+ .. _turtle-reference :
274+ .. _turtle-graphics-reference :
275+
276+ Reference
277+ =========
294278
295279.. note ::
296280
0 commit comments