diff options
Diffstat (limited to 'devdocs/python~3.12/library%2Fturtle.html')
| -rw-r--r-- | devdocs/python~3.12/library%2Fturtle.html | 1150 |
1 files changed, 1150 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fturtle.html b/devdocs/python~3.12/library%2Fturtle.html new file mode 100644 index 00000000..568433bb --- /dev/null +++ b/devdocs/python~3.12/library%2Fturtle.html @@ -0,0 +1,1150 @@ + <span id="turtle-turtle-graphics"></span><h1>turtle — Turtle graphics</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/turtle.py">Lib/turtle.py</a></p> <section id="introduction"> <h2>Introduction</h2> <p>Turtle graphics is an implementation of <a class="reference external" href="https://en.wikipedia.org/wiki/Turtle_(robot)">the popular geometric drawing tools introduced in Logo</a>, developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967.</p> <aside class="sidebar"> <p class="sidebar-title">Turtle star</p> <p>Turtle can draw intricate shapes using programs that repeat simple moves.</p> <img alt="../_images/turtle-star.png" class="align-center" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6CAMAAAC/MqoPAAADAFBMVEX7/wD///7+Nwr/LAL/Mgz+OgP/NxP/////JwD+NwH+PgH7/QD9aQb+XQX/LgX/7+z+MQL+QgL/+/v/+vr/9/b/OhT+PA3/NQ/9bwX/Qh/79gD7+wL+NAL72AL74AH74wH79AD9iAL+SAH+RQT/PRj/9fT/6+j+//n/SSf/XDz/8vD8twL/6eX9eQT9YgX/4tv//Pz9dAL7/gD+TAP/t6r/US/7+gD/YUX/loP/3tj//f3+//L7+AD+QQz/fmX/2NH8vAP/5N//TSz76QH77AH+VQL/hW7/WDf+WQP7/wb7/w38lQL+UgL9ZQX8oAP/wbX/QBj/yb/+RBX7zAL/RSH8qwL8pwT8nAH78QD+bCv+SRf/vLD71AL/eGD+TRL/iXL/s6T/zcP8sAH9fgP77wD/m4j+TwL/29T/rJ3/p5f+e0//xbr/blP+Zj38yA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w1dgAAAABJRU5ErkJggg=="> </aside> <p>In Python, turtle graphics provides a representation of a physical “turtle” (a little robot with a pen) that draws on a sheet of paper on the floor.</p> <p>It’s an effective and well-proven way for learners to encounter programming concepts and interaction with software, as it provides instant, visible feedback. It also provides convenient access to graphical output in general.</p> <p>Turtle drawing was originally created as an educational tool, to be used by teachers in the classroom. For the programmer who needs to produce some graphical output it can be a way to do that without the overhead of introducing more complex or external libraries into their work.</p> </section> <section id="tutorial"> <span id="turtle-tutorial"></span><h2>Tutorial</h2> <p>New users should start here. In this tutorial we’ll explore some of the basics of turtle drawing.</p> <section id="starting-a-turtle-environment"> <h3>Starting a turtle environment</h3> <p>In a Python shell, import all the objects of the <code>turtle</code> module:</p> <pre data-language="python">from turtle import * +</pre> <p>If you run into a <code>No module named '_tkinter'</code> error, you’ll have to install the <a class="reference internal" href="tkinter#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code>Tk interface package</code></a> on your system.</p> </section> <section id="basic-drawing"> <h3>Basic drawing</h3> <p>Send the turtle forward 100 steps:</p> <pre data-language="python">forward(100) +</pre> <p>You should see (most likely, in a new window on your display) a line drawn by the turtle, heading East. Change the direction of the turtle, so that it turns 120 degrees left (anti-clockwise):</p> <pre data-language="python">left(120) +</pre> <p>Let’s continue by drawing a triangle:</p> <pre data-language="python">forward(100) +left(120) +forward(100) +</pre> <p>Notice how the turtle, represented by an arrow, points in different directions as you steer it.</p> <p>Experiment with those commands, and also with <code>backward()</code> and <code>right()</code>.</p> <section id="pen-control"> <h4>Pen control</h4> <p>Try changing the color - for example, <code>color('blue')</code> - and width of the line - for example, <code>width(3)</code> - and then drawing again.</p> <p>You can also move the turtle around without drawing, by lifting up the pen: <code>up()</code> before moving. To start drawing again, use <code>down()</code>.</p> </section> <section id="the-turtle-s-position"> <h4>The turtle’s position</h4> <p>Send your turtle back to its starting-point (useful if it has disappeared off-screen):</p> <pre data-language="python">home() +</pre> <p>The home position is at the center of the turtle’s screen. If you ever need to know them, get the turtle’s x-y co-ordinates with:</p> <pre data-language="python">pos() +</pre> <p>Home is at <code>(0, 0)</code>.</p> <p>And after a while, it will probably help to clear the window so we can start anew:</p> <pre data-language="python">clearscreen() +</pre> </section> </section> <section id="making-algorithmic-patterns"> <h3>Making algorithmic patterns</h3> <p>Using loops, it’s possible to build up geometric patterns:</p> <pre data-language="python">for steps in range(100): + for c in ('blue', 'red', 'green'): + color(c) + forward(steps) + right(30) +</pre> <p>- which of course, are limited only by the imagination!</p> <p>Let’s draw the star shape at the top of this page. We want red lines, filled in with yellow:</p> <pre data-language="python">color('red') +fillcolor('yellow') +</pre> <p>Just as <code>up()</code> and <code>down()</code> determine whether lines will be drawn, filling can be turned on and off:</p> <pre data-language="python">begin_fill() +</pre> <p>Next we’ll create a loop:</p> <pre data-language="python">while True: + forward(200) + left(170) + if abs(pos()) < 1: + break +</pre> <p><code>abs(pos()) < 1</code> is a good way to know when the turtle is back at its home position.</p> <p>Finally, complete the filling:</p> <pre data-language="python">end_fill() +</pre> <p>(Note that filling only actually takes place when you give the <code>end_fill()</code> command.)</p> </section> </section> <section id="how-to"> <span id="turtle-how-to"></span><h2>How to…</h2> <p>This section covers some typical turtle use-cases and approaches.</p> <section id="get-started-as-quickly-as-possible"> <h3>Get started as quickly as possible</h3> <p>One of the joys of turtle graphics is the immediate, visual feedback that’s available from simple commands - it’s an excellent way to introduce children to programming ideas, with a minimum of overhead (not just children, of course).</p> <p>The turtle module makes this possible by exposing all its basic functionality as functions, available with <code>from turtle import *</code>. The <a class="reference internal" href="#turtle-tutorial"><span class="std std-ref">turtle graphics tutorial</span></a> covers this approach.</p> <p>It’s worth noting that many of the turtle commands also have even more terse equivalents, such as <code>fd()</code> for <a class="reference internal" href="#turtle.forward" title="turtle.forward"><code>forward()</code></a>. These are especially useful when working with learners for whom typing is not a skill.</p> <p>You’ll need to have the <a class="reference internal" href="tkinter#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code>Tk interface package</code></a> installed on your system for turtle graphics to work. Be warned that this is not always straightforward, so check this in advance if you’re planning to use turtle graphics with a learner.</p> </section> <section id="use-the-turtle-module-namespace"> <h3>Use the <code>turtle</code> module namespace</h3> <p>Using <code>from turtle import *</code> is convenient - but be warned that it imports a rather large collection of objects, and if you’re doing anything but turtle graphics you run the risk of a name conflict (this becomes even more an issue if you’re using turtle graphics in a script where other modules might be imported).</p> <p>The solution is to use <code>import turtle</code> - <code>fd()</code> becomes <code>turtle.fd()</code>, <code>width()</code> becomes <code>turtle.width()</code> and so on. (If typing “turtle” over and over again becomes tedious, use for example <code>import turtle +as t</code> instead.)</p> </section> <section id="use-turtle-graphics-in-a-script"> <h3>Use turtle graphics in a script</h3> <p>It’s recommended to use the <code>turtle</code> module namespace as described immediately above, for example:</p> <pre data-language="python">import turtle as t +from random import random + +for i in range(100): + steps = int(random() * 100) + angle = int(random() * 360) + t.right(angle) + t.fd(steps) +</pre> <p>Another step is also required though - as soon as the script ends, Python will also close the turtle’s window. Add:</p> <pre data-language="python">t.mainloop() +</pre> <p>to the end of the script. The script will now wait to be dismissed and will not exit until it is terminated, for example by closing the turtle graphics window.</p> </section> <section id="use-object-oriented-turtle-graphics"> <h3>Use object-oriented turtle graphics</h3> <div class="admonition seealso"> <p class="admonition-title">See also</p> <p><a class="reference internal" href="#turtle-explanation"><span class="std std-ref">Explanation of the object-oriented interface</span></a></p> </div> <p>Other than for very basic introductory purposes, or for trying things out as quickly as possible, it’s more usual and much more powerful to use the object-oriented approach to turtle graphics. For example, this allows multiple turtles on screen at once.</p> <p>In this approach, the various turtle commands are methods of objects (mostly of <code>Turtle</code> objects). You <em>can</em> use the object-oriented approach in the shell, but it would be more typical in a Python script.</p> <p>The example above then becomes:</p> <pre data-language="python">from turtle import Turtle +from random import random + +t = Turtle() +for i in range(100): + steps = int(random() * 100) + angle = int(random() * 360) + t.right(angle) + t.fd(steps) + +t.screen.mainloop() +</pre> <p>Note the last line. <code>t.screen</code> is an instance of the <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a> that a Turtle instance exists on; it’s created automatically along with the turtle.</p> <p>The turtle’s screen can be customised, for example:</p> <pre data-language="python">t.screen.title('Object-oriented turtle demo') +t.screen.bgcolor("orange") +</pre> </section> </section> <section id="turtle-graphics-reference"> <h2>Turtle graphics reference</h2> <div class="admonition note"> <p class="admonition-title">Note</p> <p>In the following documentation the argument list for functions is given. Methods, of course, have the additional first argument <em>self</em> which is omitted here.</p> </div> <section id="turtle-methods"> <h3>Turtle methods</h3> <dl> <dt>Turtle motion</dt> +<dd> +<dl> <dt>Move and draw</dt> +<dd> </dd> <dt>Tell Turtle’s state</dt> +<dd> </dd> <dt>Setting and measurement</dt> +<dd> </dd> </dl> </dd> <dt>Pen control</dt> +<dd> +<dl> <dt>Drawing state</dt> +<dd> </dd> <dt>Color control</dt> +<dd> </dd> <dt>Filling</dt> +<dd> </dd> <dt>More drawing control</dt> +<dd> </dd> </dl> </dd> <dt>Turtle state</dt> +<dd> +<dl> <dt>Visibility</dt> +<dd> </dd> <dt>Appearance</dt> +<dd> </dd> </dl> </dd> <dt>Using events</dt> +<dd> </dd> <dt>Special Turtle methods</dt> +<dd> </dd> </dl> </section> <section id="methods-of-turtlescreen-screen"> <h3>Methods of TurtleScreen/Screen</h3> <dl> <dt>Window control</dt> +<dd> </dd> <dt>Animation control</dt> +<dd> </dd> <dt>Using screen events</dt> +<dd> </dd> <dt>Settings and special methods</dt> +<dd> </dd> <dt>Input methods</dt> +<dd> </dd> <dt>Methods specific to Screen</dt> +<dd> </dd> </dl> </section> </section> <section id="methods-of-rawturtle-turtle-and-corresponding-functions"> <h2>Methods of RawTurtle/Turtle and corresponding functions</h2> <p>Most of the examples in this section refer to a Turtle instance called <code>turtle</code>.</p> <section id="turtle-motion"> <h3>Turtle motion</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.forward"> +<code>turtle.forward(distance)</code> </dt> <dt class="sig sig-object py" id="turtle.fd"> +<code>turtle.fd(distance)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>distance</strong> – a number (integer or float)</p> </dd> </dl> <p>Move the turtle forward by the specified <em>distance</em>, in the direction the turtle is headed.</p> <pre data-language="pycon3">>>> turtle.position() +(0.00,0.00) +>>> turtle.forward(25) +>>> turtle.position() +(25.00,0.00) +>>> turtle.forward(-75) +>>> turtle.position() +(-50.00,0.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.back"> +<code>turtle.back(distance)</code> </dt> <dt class="sig sig-object py" id="turtle.bk"> +<code>turtle.bk(distance)</code> </dt> <dt class="sig sig-object py" id="turtle.backward"> +<code>turtle.backward(distance)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>distance</strong> – a number</p> </dd> </dl> <p>Move the turtle backward by <em>distance</em>, opposite to the direction the turtle is headed. Do not change the turtle’s heading.</p> <pre data-language="pycon3">>>> turtle.position() +(0.00,0.00) +>>> turtle.backward(30) +>>> turtle.position() +(-30.00,0.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.right"> +<code>turtle.right(angle)</code> </dt> <dt class="sig sig-object py" id="turtle.rt"> +<code>turtle.rt(angle)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>angle</strong> – a number (integer or float)</p> </dd> </dl> <p>Turn turtle right by <em>angle</em> units. (Units are by default degrees, but can be set via the <a class="reference internal" href="#turtle.degrees" title="turtle.degrees"><code>degrees()</code></a> and <a class="reference internal" href="#turtle.radians" title="turtle.radians"><code>radians()</code></a> functions.) Angle orientation depends on the turtle mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code>mode()</code></a>.</p> <pre data-language="pycon3">>>> turtle.heading() +22.0 +>>> turtle.right(45) +>>> turtle.heading() +337.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.left"> +<code>turtle.left(angle)</code> </dt> <dt class="sig sig-object py" id="turtle.lt"> +<code>turtle.lt(angle)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>angle</strong> – a number (integer or float)</p> </dd> </dl> <p>Turn turtle left by <em>angle</em> units. (Units are by default degrees, but can be set via the <a class="reference internal" href="#turtle.degrees" title="turtle.degrees"><code>degrees()</code></a> and <a class="reference internal" href="#turtle.radians" title="turtle.radians"><code>radians()</code></a> functions.) Angle orientation depends on the turtle mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code>mode()</code></a>.</p> <pre data-language="pycon3">>>> turtle.heading() +22.0 +>>> turtle.left(45) +>>> turtle.heading() +67.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.goto"> +<code>turtle.goto(x, y=None)</code> </dt> <dt class="sig sig-object py" id="turtle.setpos"> +<code>turtle.setpos(x, y=None)</code> </dt> <dt class="sig sig-object py" id="turtle.setposition"> +<code>turtle.setposition(x, y=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>x</strong> – a number or a pair/vector of numbers</li> <li> +<strong>y</strong> – a number or <code>None</code> +</li> </ul> </dd> </dl> <p>If <em>y</em> is <code>None</code>, <em>x</em> must be a pair of coordinates or a <a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code>Vec2D</code></a> (e.g. as returned by <a class="reference internal" href="#turtle.pos" title="turtle.pos"><code>pos()</code></a>).</p> <p>Move turtle to an absolute position. If the pen is down, draw line. Do not change the turtle’s orientation.</p> <pre data-language="pycon3">>>> tp = turtle.pos() +>>> tp +(0.00,0.00) +>>> turtle.setpos(60,30) +>>> turtle.pos() +(60.00,30.00) +>>> turtle.setpos((20,80)) +>>> turtle.pos() +(20.00,80.00) +>>> turtle.setpos(tp) +>>> turtle.pos() +(0.00,0.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.teleport"> +<code>turtle.teleport(x, y=None, *, fill_gap=False)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>x</strong> – a number or <code>None</code> +</li> <li> +<strong>y</strong> – a number or <code>None</code> +</li> <li> +<strong>fill_gap</strong> – a boolean</li> </ul> </dd> </dl> <p>Move turtle to an absolute position. Unlike goto(x, y), a line will not be drawn. The turtle’s orientation does not change. If currently filling, the polygon(s) teleported from will be filled after leaving, and filling will begin again after teleporting. This can be disabled with fill_gap=True, which makes the imaginary line traveled during teleporting act as a fill barrier like in goto(x, y).</p> <pre data-language="pycon3">>>> tp = turtle.pos() +>>> tp +(0.00,0.00) +>>> turtle.teleport(60) +>>> turtle.pos() +(60.00,0.00) +>>> turtle.teleport(y=10) +>>> turtle.pos() +(60.00,10.00) +>>> turtle.teleport(20, 30) +>>> turtle.pos() +(20.00,30.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.setx"> +<code>turtle.setx(x)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>x</strong> – a number (integer or float)</p> </dd> </dl> <p>Set the turtle’s first coordinate to <em>x</em>, leave second coordinate unchanged.</p> <pre data-language="pycon3">>>> turtle.position() +(0.00,240.00) +>>> turtle.setx(10) +>>> turtle.position() +(10.00,240.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.sety"> +<code>turtle.sety(y)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>y</strong> – a number (integer or float)</p> </dd> </dl> <p>Set the turtle’s second coordinate to <em>y</em>, leave first coordinate unchanged.</p> <pre data-language="pycon3">>>> turtle.position() +(0.00,40.00) +>>> turtle.sety(-10) +>>> turtle.position() +(0.00,-10.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.setheading"> +<code>turtle.setheading(to_angle)</code> </dt> <dt class="sig sig-object py" id="turtle.seth"> +<code>turtle.seth(to_angle)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>to_angle</strong> – a number (integer or float)</p> </dd> </dl> <p>Set the orientation of the turtle to <em>to_angle</em>. Here are some common directions in degrees:</p> <table class="docutils align-default"> <thead> <tr> +<th class="head"><p>standard mode</p></th> <th class="head"><p>logo mode</p></th> </tr> </thead> <tr> +<td><p>0 - east</p></td> <td><p>0 - north</p></td> </tr> <tr> +<td><p>90 - north</p></td> <td><p>90 - east</p></td> </tr> <tr> +<td><p>180 - west</p></td> <td><p>180 - south</p></td> </tr> <tr> +<td><p>270 - south</p></td> <td><p>270 - west</p></td> </tr> </table> <pre data-language="pycon3">>>> turtle.setheading(90) +>>> turtle.heading() +90.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.home"> +<code>turtle.home()</code> </dt> <dd> +<p>Move turtle to the origin – coordinates (0,0) – and set its heading to its start-orientation (which depends on the mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code>mode()</code></a>).</p> <pre data-language="pycon3">>>> turtle.heading() +90.0 +>>> turtle.position() +(0.00,-10.00) +>>> turtle.home() +>>> turtle.position() +(0.00,0.00) +>>> turtle.heading() +0.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.circle"> +<code>turtle.circle(radius, extent=None, steps=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>radius</strong> – a number</li> <li> +<strong>extent</strong> – a number (or <code>None</code>)</li> <li> +<strong>steps</strong> – an integer (or <code>None</code>)</li> </ul> </dd> </dl> <p>Draw a circle with given <em>radius</em>. The center is <em>radius</em> units left of the turtle; <em>extent</em> – an angle – determines which part of the circle is drawn. If <em>extent</em> is not given, draw the entire circle. If <em>extent</em> is not a full circle, one endpoint of the arc is the current pen position. Draw the arc in counterclockwise direction if <em>radius</em> is positive, otherwise in clockwise direction. Finally the direction of the turtle is changed by the amount of <em>extent</em>.</p> <p>As the circle is approximated by an inscribed regular polygon, <em>steps</em> determines the number of steps to use. If not given, it will be calculated automatically. May be used to draw regular polygons.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.position() +(0.00,0.00) +>>> turtle.heading() +0.0 +>>> turtle.circle(50) +>>> turtle.position() +(-0.00,0.00) +>>> turtle.heading() +0.0 +>>> turtle.circle(120, 180) # draw a semicircle +>>> turtle.position() +(0.00,240.00) +>>> turtle.heading() +180.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.dot"> +<code>turtle.dot(size=None, *color)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>size</strong> – an integer >= 1 (if given)</li> <li> +<strong>color</strong> – a colorstring or a numeric color tuple</li> </ul> </dd> </dl> <p>Draw a circular dot with diameter <em>size</em>, using <em>color</em>. If <em>size</em> is not given, the maximum of pensize+4 and 2*pensize is used.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.dot() +>>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50) +>>> turtle.position() +(100.00,-0.00) +>>> turtle.heading() +0.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.stamp"> +<code>turtle.stamp()</code> </dt> <dd> +<p>Stamp a copy of the turtle shape onto the canvas at the current turtle position. Return a stamp_id for that stamp, which can be used to delete it by calling <code>clearstamp(stamp_id)</code>.</p> <pre data-language="pycon3">>>> turtle.color("blue") +>>> stamp_id = turtle.stamp() +>>> turtle.fd(50) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.clearstamp"> +<code>turtle.clearstamp(stampid)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>stampid</strong> – an integer, must be return value of previous <a class="reference internal" href="#turtle.stamp" title="turtle.stamp"><code>stamp()</code></a> call</p> </dd> </dl> <p>Delete stamp with given <em>stampid</em>.</p> <pre data-language="pycon3">>>> turtle.position() +(150.00,-0.00) +>>> turtle.color("blue") +>>> astamp = turtle.stamp() +>>> turtle.fd(50) +>>> turtle.position() +(200.00,-0.00) +>>> turtle.clearstamp(astamp) +>>> turtle.position() +(200.00,-0.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.clearstamps"> +<code>turtle.clearstamps(n=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>n</strong> – an integer (or <code>None</code>)</p> </dd> </dl> <p>Delete all or first/last <em>n</em> of turtle’s stamps. If <em>n</em> is <code>None</code>, delete all stamps, if <em>n</em> > 0 delete first <em>n</em> stamps, else if <em>n</em> < 0 delete last <em>n</em> stamps.</p> <pre data-language="pycon3">>>> for i in range(8): +... unused_stamp_id = turtle.stamp() +... turtle.fd(30) +>>> turtle.clearstamps(2) +>>> turtle.clearstamps(-2) +>>> turtle.clearstamps() +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.undo"> +<code>turtle.undo()</code> </dt> <dd> +<p>Undo (repeatedly) the last turtle action(s). Number of available undo actions is determined by the size of the undobuffer.</p> <pre data-language="pycon3">>>> for i in range(4): +... turtle.fd(50); turtle.lt(80) +... +>>> for i in range(8): +... turtle.undo() +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.speed"> +<code>turtle.speed(speed=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>speed</strong> – an integer in the range 0..10 or a speedstring (see below)</p> </dd> </dl> <p>Set the turtle’s speed to an integer value in the range 0..10. If no argument is given, return current speed.</p> <p>If input is a number greater than 10 or smaller than 0.5, speed is set to 0. Speedstrings are mapped to speedvalues as follows:</p> <ul class="simple"> <li>“fastest”: 0</li> <li>“fast”: 10</li> <li>“normal”: 6</li> <li>“slow”: 3</li> <li>“slowest”: 1</li> </ul> <p>Speeds from 1 to 10 enforce increasingly faster animation of line drawing and turtle turning.</p> <p>Attention: <em>speed</em> = 0 means that <em>no</em> animation takes place. forward/back makes turtle jump and likewise left/right make the turtle turn instantly.</p> <pre data-language="pycon3">>>> turtle.speed() +3 +>>> turtle.speed('normal') +>>> turtle.speed() +6 +>>> turtle.speed(9) +>>> turtle.speed() +9 +</pre> </dd> +</dl> </section> <section id="tell-turtle-s-state"> <h3>Tell Turtle’s state</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.position"> +<code>turtle.position()</code> </dt> <dt class="sig sig-object py" id="turtle.pos"> +<code>turtle.pos()</code> </dt> <dd> +<p>Return the turtle’s current location (x,y) (as a <a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code>Vec2D</code></a> vector).</p> <pre data-language="pycon3">>>> turtle.pos() +(440.00,-0.00) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.towards"> +<code>turtle.towards(x, y=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>x</strong> – a number or a pair/vector of numbers or a turtle instance</li> <li> +<strong>y</strong> – a number if <em>x</em> is a number, else <code>None</code> +</li> </ul> </dd> </dl> <p>Return the angle between the line from turtle position to position specified by (x,y), the vector or the other turtle. This depends on the turtle’s start orientation which depends on the mode - “standard”/”world” or “logo”.</p> <pre data-language="pycon3">>>> turtle.goto(10, 10) +>>> turtle.towards(0,0) +225.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.xcor"> +<code>turtle.xcor()</code> </dt> <dd> +<p>Return the turtle’s x coordinate.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.left(50) +>>> turtle.forward(100) +>>> turtle.pos() +(64.28,76.60) +>>> print(round(turtle.xcor(), 5)) +64.27876 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.ycor"> +<code>turtle.ycor()</code> </dt> <dd> +<p>Return the turtle’s y coordinate.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.left(60) +>>> turtle.forward(100) +>>> print(turtle.pos()) +(50.00,86.60) +>>> print(round(turtle.ycor(), 5)) +86.60254 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.heading"> +<code>turtle.heading()</code> </dt> <dd> +<p>Return the turtle’s current heading (value depends on the turtle mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code>mode()</code></a>).</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.left(67) +>>> turtle.heading() +67.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.distance"> +<code>turtle.distance(x, y=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>x</strong> – a number or a pair/vector of numbers or a turtle instance</li> <li> +<strong>y</strong> – a number if <em>x</em> is a number, else <code>None</code> +</li> </ul> </dd> </dl> <p>Return the distance from the turtle to (x,y), the given vector, or the given other turtle, in turtle step units.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.distance(30,40) +50.0 +>>> turtle.distance((30,40)) +50.0 +>>> joe = Turtle() +>>> joe.forward(77) +>>> turtle.distance(joe) +77.0 +</pre> </dd> +</dl> </section> <section id="settings-for-measurement"> <h3>Settings for measurement</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.degrees"> +<code>turtle.degrees(fullcircle=360.0)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>fullcircle</strong> – a number</p> </dd> </dl> <p>Set angle measurement units, i.e. set number of “degrees” for a full circle. Default value is 360 degrees.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.left(90) +>>> turtle.heading() +90.0 + +Change angle measurement unit to grad (also known as gon, +grade, or gradian and equals 1/100-th of the right angle.) +>>> turtle.degrees(400.0) +>>> turtle.heading() +100.0 +>>> turtle.degrees(360) +>>> turtle.heading() +90.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.radians"> +<code>turtle.radians()</code> </dt> <dd> +<p>Set the angle measurement units to radians. Equivalent to <code>degrees(2*math.pi)</code>.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.left(90) +>>> turtle.heading() +90.0 +>>> turtle.radians() +>>> turtle.heading() +1.5707963267948966 +</pre> </dd> +</dl> </section> <section id="id1"> <h3>Pen control</h3> <section id="drawing-state"> <h4>Drawing state</h4> <dl class="py function"> <dt class="sig sig-object py" id="turtle.pendown"> +<code>turtle.pendown()</code> </dt> <dt class="sig sig-object py" id="turtle.pd"> +<code>turtle.pd()</code> </dt> <dt class="sig sig-object py" id="turtle.down"> +<code>turtle.down()</code> </dt> <dd> +<p>Pull the pen down – drawing when moving.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.penup"> +<code>turtle.penup()</code> </dt> <dt class="sig sig-object py" id="turtle.pu"> +<code>turtle.pu()</code> </dt> <dt class="sig sig-object py" id="turtle.up"> +<code>turtle.up()</code> </dt> <dd> +<p>Pull the pen up – no drawing when moving.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.pensize"> +<code>turtle.pensize(width=None)</code> </dt> <dt class="sig sig-object py" id="turtle.width"> +<code>turtle.width(width=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>width</strong> – a positive number</p> </dd> </dl> <p>Set the line thickness to <em>width</em> or return it. If resizemode is set to “auto” and turtleshape is a polygon, that polygon is drawn with the same line thickness. If no argument is given, the current pensize is returned.</p> <pre data-language="pycon3">>>> turtle.pensize() +1 +>>> turtle.pensize(10) # from here on lines of width 10 are drawn +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.pen"> +<code>turtle.pen(pen=None, **pendict)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>pen</strong> – a dictionary with some or all of the below listed keys</li> <li> +<strong>pendict</strong> – one or more keyword-arguments with the below listed keys as keywords</li> </ul> </dd> </dl> <p>Return or set the pen’s attributes in a “pen-dictionary” with the following key/value pairs:</p> <ul class="simple"> <li>“shown”: True/False</li> <li>“pendown”: True/False</li> <li>“pencolor”: color-string or color-tuple</li> <li>“fillcolor”: color-string or color-tuple</li> <li>“pensize”: positive number</li> <li>“speed”: number in range 0..10</li> <li>“resizemode”: “auto” or “user” or “noresize”</li> <li>“stretchfactor”: (positive number, positive number)</li> <li>“outline”: positive number</li> <li>“tilt”: number</li> </ul> <p>This dictionary can be used as argument for a subsequent call to <a class="reference internal" href="#turtle.pen" title="turtle.pen"><code>pen()</code></a> to restore the former pen-state. Moreover one or more of these attributes can be provided as keyword-arguments. This can be used to set several pen attributes in one statement.</p> <pre data-language="pycon3">>>> turtle.pen(fillcolor="black", pencolor="red", pensize=10) +>>> sorted(turtle.pen().items()) +[('fillcolor', 'black'), ('outline', 1), ('pencolor', 'red'), + ('pendown', True), ('pensize', 10), ('resizemode', 'noresize'), + ('shearfactor', 0.0), ('shown', True), ('speed', 9), + ('stretchfactor', (1.0, 1.0)), ('tilt', 0.0)] +>>> penstate=turtle.pen() +>>> turtle.color("yellow", "") +>>> turtle.penup() +>>> sorted(turtle.pen().items())[:3] +[('fillcolor', ''), ('outline', 1), ('pencolor', 'yellow')] +>>> turtle.pen(penstate, fillcolor="green") +>>> sorted(turtle.pen().items())[:3] +[('fillcolor', 'green'), ('outline', 1), ('pencolor', 'red')] +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.isdown"> +<code>turtle.isdown()</code> </dt> <dd> +<p>Return <code>True</code> if pen is down, <code>False</code> if it’s up.</p> <pre data-language="pycon3">>>> turtle.penup() +>>> turtle.isdown() +False +>>> turtle.pendown() +>>> turtle.isdown() +True +</pre> </dd> +</dl> </section> <section id="color-control"> <h4>Color control</h4> <dl class="py function"> <dt class="sig sig-object py" id="turtle.pencolor"> +<code>turtle.pencolor(*args)</code> </dt> <dd> +<p>Return or set the pencolor.</p> <p>Four input formats are allowed:</p> <dl class="simple"> <dt> +<code>pencolor()</code> </dt> +<dd> +<p>Return the current pencolor as color specification string or as a tuple (see example). May be used as input to another color/pencolor/fillcolor call.</p> </dd> <dt> +<code>pencolor(colorstring)</code> </dt> +<dd> +<p>Set pencolor to <em>colorstring</em>, which is a Tk color specification string, such as <code>"red"</code>, <code>"yellow"</code>, or <code>"#33cc8c"</code>.</p> </dd> <dt> +<code>pencolor((r, g, b))</code> </dt> +<dd> +<p>Set pencolor to the RGB color represented by the tuple of <em>r</em>, <em>g</em>, and <em>b</em>. Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode, where colormode is either 1.0 or 255 (see <a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code>colormode()</code></a>).</p> </dd> <dt> +<code>pencolor(r, g, b)</code> </dt> +<dd> +<p>Set pencolor to the RGB color represented by <em>r</em>, <em>g</em>, and <em>b</em>. Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode.</p> </dd> </dl> <p>If turtleshape is a polygon, the outline of that polygon is drawn with the newly set pencolor.</p> <pre data-language="pycon3">>>> colormode() +1.0 +>>> turtle.pencolor() +'red' +>>> turtle.pencolor("brown") +>>> turtle.pencolor() +'brown' +>>> tup = (0.2, 0.8, 0.55) +>>> turtle.pencolor(tup) +>>> turtle.pencolor() +(0.2, 0.8, 0.5490196078431373) +>>> colormode(255) +>>> turtle.pencolor() +(51.0, 204.0, 140.0) +>>> turtle.pencolor('#32c18f') +>>> turtle.pencolor() +(50.0, 193.0, 143.0) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.fillcolor"> +<code>turtle.fillcolor(*args)</code> </dt> <dd> +<p>Return or set the fillcolor.</p> <p>Four input formats are allowed:</p> <dl class="simple"> <dt> +<code>fillcolor()</code> </dt> +<dd> +<p>Return the current fillcolor as color specification string, possibly in tuple format (see example). May be used as input to another color/pencolor/fillcolor call.</p> </dd> <dt> +<code>fillcolor(colorstring)</code> </dt> +<dd> +<p>Set fillcolor to <em>colorstring</em>, which is a Tk color specification string, such as <code>"red"</code>, <code>"yellow"</code>, or <code>"#33cc8c"</code>.</p> </dd> <dt> +<code>fillcolor((r, g, b))</code> </dt> +<dd> +<p>Set fillcolor to the RGB color represented by the tuple of <em>r</em>, <em>g</em>, and <em>b</em>. Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode, where colormode is either 1.0 or 255 (see <a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code>colormode()</code></a>).</p> </dd> <dt> +<code>fillcolor(r, g, b)</code> </dt> +<dd> +<p>Set fillcolor to the RGB color represented by <em>r</em>, <em>g</em>, and <em>b</em>. Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode.</p> </dd> </dl> <p>If turtleshape is a polygon, the interior of that polygon is drawn with the newly set fillcolor.</p> <pre data-language="pycon3">>>> turtle.fillcolor("violet") +>>> turtle.fillcolor() +'violet' +>>> turtle.pencolor() +(50.0, 193.0, 143.0) +>>> turtle.fillcolor((50, 193, 143)) # Integers, not floats +>>> turtle.fillcolor() +(50.0, 193.0, 143.0) +>>> turtle.fillcolor('#ffffff') +>>> turtle.fillcolor() +(255.0, 255.0, 255.0) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.color"> +<code>turtle.color(*args)</code> </dt> <dd> +<p>Return or set pencolor and fillcolor.</p> <p>Several input formats are allowed. They use 0 to 3 arguments as follows:</p> <dl class="simple"> <dt> +<code>color()</code> </dt> +<dd> +<p>Return the current pencolor and the current fillcolor as a pair of color specification strings or tuples as returned by <a class="reference internal" href="#turtle.pencolor" title="turtle.pencolor"><code>pencolor()</code></a> and <a class="reference internal" href="#turtle.fillcolor" title="turtle.fillcolor"><code>fillcolor()</code></a>.</p> </dd> <dt> +<code>color(colorstring), color((r,g,b)), color(r,g,b)</code> </dt> +<dd> +<p>Inputs as in <a class="reference internal" href="#turtle.pencolor" title="turtle.pencolor"><code>pencolor()</code></a>, set both, fillcolor and pencolor, to the given value.</p> </dd> <dt> +<code>color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2))</code> </dt> +<dd> +<p>Equivalent to <code>pencolor(colorstring1)</code> and <code>fillcolor(colorstring2)</code> and analogously if the other input format is used.</p> </dd> </dl> <p>If turtleshape is a polygon, outline and interior of that polygon is drawn with the newly set colors.</p> <pre data-language="pycon3">>>> turtle.color("red", "green") +>>> turtle.color() +('red', 'green') +>>> color("#285078", "#a0c8f0") +>>> color() +((40.0, 80.0, 120.0), (160.0, 200.0, 240.0)) +</pre> </dd> +</dl> <p>See also: Screen method <a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code>colormode()</code></a>.</p> </section> <section id="filling"> <h4>Filling</h4> <dl class="py function"> <dt class="sig sig-object py" id="turtle.filling"> +<code>turtle.filling()</code> </dt> <dd> +<p>Return fillstate (<code>True</code> if filling, <code>False</code> else).</p> <pre data-language="pycon3">>>> turtle.begin_fill() +>>> if turtle.filling(): +... turtle.pensize(5) +... else: +... turtle.pensize(3) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.begin_fill"> +<code>turtle.begin_fill()</code> </dt> <dd> +<p>To be called just before drawing a shape to be filled.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.end_fill"> +<code>turtle.end_fill()</code> </dt> <dd> +<p>Fill the shape drawn after the last call to <a class="reference internal" href="#turtle.begin_fill" title="turtle.begin_fill"><code>begin_fill()</code></a>.</p> <p>Whether or not overlap regions for self-intersecting polygons or multiple shapes are filled depends on the operating system graphics, type of overlap, and number of overlaps. For example, the Turtle star above may be either all yellow or have some white regions.</p> <pre data-language="pycon3">>>> turtle.color("black", "red") +>>> turtle.begin_fill() +>>> turtle.circle(80) +>>> turtle.end_fill() +</pre> </dd> +</dl> </section> <section id="more-drawing-control"> <h4>More drawing control</h4> <dl class="py function"> <dt class="sig sig-object py" id="turtle.reset"> +<code>turtle.reset()</code> </dt> <dd> +<p>Delete the turtle’s drawings from the screen, re-center the turtle and set variables to the default values.</p> <pre data-language="pycon3">>>> turtle.goto(0,-22) +>>> turtle.left(100) +>>> turtle.position() +(0.00,-22.00) +>>> turtle.heading() +100.0 +>>> turtle.reset() +>>> turtle.position() +(0.00,0.00) +>>> turtle.heading() +0.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.clear"> +<code>turtle.clear()</code> </dt> <dd> +<p>Delete the turtle’s drawings from the screen. Do not move turtle. State and position of the turtle as well as drawings of other turtles are not affected.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.write"> +<code>turtle.write(arg, move=False, align='left', font=('Arial', 8, 'normal'))</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>arg</strong> – object to be written to the TurtleScreen</li> <li> +<strong>move</strong> – True/False</li> <li> +<strong>align</strong> – one of the strings “left”, “center” or right”</li> <li> +<strong>font</strong> – a triple (fontname, fontsize, fonttype)</li> </ul> </dd> </dl> <p>Write text - the string representation of <em>arg</em> - at the current turtle position according to <em>align</em> (“left”, “center” or “right”) and with the given font. If <em>move</em> is true, the pen is moved to the bottom-right corner of the text. By default, <em>move</em> is <code>False</code>.</p> <pre data-language="python">>>> turtle.write("Home = ", True, align="center") +>>> turtle.write((0,0), True) +</pre> </dd> +</dl> </section> </section> <section id="turtle-state"> <h3>Turtle state</h3> <section id="visibility"> <h4>Visibility</h4> <dl class="py function"> <dt class="sig sig-object py" id="turtle.hideturtle"> +<code>turtle.hideturtle()</code> </dt> <dt class="sig sig-object py" id="turtle.ht"> +<code>turtle.ht()</code> </dt> <dd> +<p>Make the turtle invisible. It’s a good idea to do this while you’re in the middle of doing some complex drawing, because hiding the turtle speeds up the drawing observably.</p> <pre data-language="pycon3">>>> turtle.hideturtle() +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.showturtle"> +<code>turtle.showturtle()</code> </dt> <dt class="sig sig-object py" id="turtle.st"> +<code>turtle.st()</code> </dt> <dd> +<p>Make the turtle visible.</p> <pre data-language="pycon3">>>> turtle.showturtle() +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.isvisible"> +<code>turtle.isvisible()</code> </dt> <dd> +<p>Return <code>True</code> if the Turtle is shown, <code>False</code> if it’s hidden.</p> <pre data-language="python">>>> turtle.hideturtle() +>>> turtle.isvisible() +False +>>> turtle.showturtle() +>>> turtle.isvisible() +True +</pre> </dd> +</dl> </section> <section id="appearance"> <h4>Appearance</h4> <dl class="py function"> <dt class="sig sig-object py" id="turtle.shape"> +<code>turtle.shape(name=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>name</strong> – a string which is a valid shapename</p> </dd> </dl> <p>Set turtle shape to shape with given <em>name</em> or, if name is not given, return name of current shape. Shape with <em>name</em> must exist in the TurtleScreen’s shape dictionary. Initially there are the following polygon shapes: “arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”. To learn about how to deal with shapes see Screen method <a class="reference internal" href="#turtle.register_shape" title="turtle.register_shape"><code>register_shape()</code></a>.</p> <pre data-language="pycon3">>>> turtle.shape() +'classic' +>>> turtle.shape("turtle") +>>> turtle.shape() +'turtle' +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.resizemode"> +<code>turtle.resizemode(rmode=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>rmode</strong> – one of the strings “auto”, “user”, “noresize”</p> </dd> </dl> <p>Set resizemode to one of the values: “auto”, “user”, “noresize”. If <em>rmode</em> is not given, return current resizemode. Different resizemodes have the following effects:</p> <ul class="simple"> <li>“auto”: adapts the appearance of the turtle corresponding to the value of pensize.</li> <li>“user”: adapts the appearance of the turtle according to the values of stretchfactor and outlinewidth (outline), which are set by <a class="reference internal" href="#turtle.shapesize" title="turtle.shapesize"><code>shapesize()</code></a>.</li> <li>“noresize”: no adaption of the turtle’s appearance takes place.</li> </ul> <p><code>resizemode("user")</code> is called by <a class="reference internal" href="#turtle.shapesize" title="turtle.shapesize"><code>shapesize()</code></a> when used with arguments.</p> <pre data-language="pycon3">>>> turtle.resizemode() +'noresize' +>>> turtle.resizemode("auto") +>>> turtle.resizemode() +'auto' +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.shapesize"> +<code>turtle.shapesize(stretch_wid=None, stretch_len=None, outline=None)</code> </dt> <dt class="sig sig-object py" id="turtle.turtlesize"> +<code>turtle.turtlesize(stretch_wid=None, stretch_len=None, outline=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>stretch_wid</strong> – positive number</li> <li> +<strong>stretch_len</strong> – positive number</li> <li> +<strong>outline</strong> – positive number</li> </ul> </dd> </dl> <p>Return or set the pen’s attributes x/y-stretchfactors and/or outline. Set resizemode to “user”. If and only if resizemode is set to “user”, the turtle will be displayed stretched according to its stretchfactors: <em>stretch_wid</em> is stretchfactor perpendicular to its orientation, <em>stretch_len</em> is stretchfactor in direction of its orientation, <em>outline</em> determines the width of the shape’s outline.</p> <pre data-language="pycon3">>>> turtle.shapesize() +(1.0, 1.0, 1) +>>> turtle.resizemode("user") +>>> turtle.shapesize(5, 5, 12) +>>> turtle.shapesize() +(5, 5, 12) +>>> turtle.shapesize(outline=8) +>>> turtle.shapesize() +(5, 5, 8) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.shearfactor"> +<code>turtle.shearfactor(shear=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>shear</strong> – number (optional)</p> </dd> </dl> <p>Set or return the current shearfactor. Shear the turtleshape according to the given shearfactor shear, which is the tangent of the shear angle. Do <em>not</em> change the turtle’s heading (direction of movement). If shear is not given: return the current shearfactor, i. e. the tangent of the shear angle, by which lines parallel to the heading of the turtle are sheared.</p> <pre data-language="pycon3">>>> turtle.shape("circle") +>>> turtle.shapesize(5,2) +>>> turtle.shearfactor(0.5) +>>> turtle.shearfactor() +0.5 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.tilt"> +<code>turtle.tilt(angle)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>angle</strong> – a number</p> </dd> </dl> <p>Rotate the turtleshape by <em>angle</em> from its current tilt-angle, but do <em>not</em> change the turtle’s heading (direction of movement).</p> <pre data-language="pycon3">>>> turtle.reset() +>>> turtle.shape("circle") +>>> turtle.shapesize(5,2) +>>> turtle.tilt(30) +>>> turtle.fd(50) +>>> turtle.tilt(30) +>>> turtle.fd(50) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.settiltangle"> +<code>turtle.settiltangle(angle)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>angle</strong> – a number</p> </dd> </dl> <p>Rotate the turtleshape to point in the direction specified by <em>angle</em>, regardless of its current tilt-angle. <em>Do not</em> change the turtle’s heading (direction of movement).</p> <pre data-language="pycon3">>>> turtle.reset() +>>> turtle.shape("circle") +>>> turtle.shapesize(5,2) +>>> turtle.settiltangle(45) +>>> turtle.fd(50) +>>> turtle.settiltangle(-45) +>>> turtle.fd(50) +</pre> <div class="deprecated"> <p><span class="versionmodified deprecated">Deprecated since version 3.1.</span></p> </div> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.tiltangle"> +<code>turtle.tiltangle(angle=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>angle</strong> – a number (optional)</p> </dd> </dl> <p>Set or return the current tilt-angle. If angle is given, rotate the turtleshape to point in the direction specified by angle, regardless of its current tilt-angle. Do <em>not</em> change the turtle’s heading (direction of movement). If angle is not given: return the current tilt-angle, i. e. the angle between the orientation of the turtleshape and the heading of the turtle (its direction of movement).</p> <pre data-language="pycon3">>>> turtle.reset() +>>> turtle.shape("circle") +>>> turtle.shapesize(5,2) +>>> turtle.tilt(45) +>>> turtle.tiltangle() +45.0 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.shapetransform"> +<code>turtle.shapetransform(t11=None, t12=None, t21=None, t22=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>t11</strong> – a number (optional)</li> <li> +<strong>t12</strong> – a number (optional)</li> <li> +<strong>t21</strong> – a number (optional)</li> <li> +<strong>t12</strong> – a number (optional)</li> </ul> </dd> </dl> <p>Set or return the current transformation matrix of the turtle shape.</p> <p>If none of the matrix elements are given, return the transformation matrix as a tuple of 4 elements. Otherwise set the given elements and transform the turtleshape according to the matrix consisting of first row t11, t12 and second row t21, t22. The determinant t11 * t22 - t12 * t21 must not be zero, otherwise an error is raised. Modify stretchfactor, shearfactor and tiltangle according to the given matrix.</p> <pre data-language="pycon3">>>> turtle = Turtle() +>>> turtle.shape("square") +>>> turtle.shapesize(4,2) +>>> turtle.shearfactor(-0.5) +>>> turtle.shapetransform() +(4.0, -1.0, -0.0, 2.0) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.get_shapepoly"> +<code>turtle.get_shapepoly()</code> </dt> <dd> +<p>Return the current shape polygon as tuple of coordinate pairs. This can be used to define a new shape or components of a compound shape.</p> <pre data-language="pycon3">>>> turtle.shape("square") +>>> turtle.shapetransform(4, -1, 0, 2) +>>> turtle.get_shapepoly() +((50, -20), (30, 20), (-50, 20), (-30, -20)) +</pre> </dd> +</dl> </section> </section> <section id="using-events"> <h3>Using events</h3> <dl class="py function"> <dt class="sig sig-object py"> <span class="sig-prename descclassname">turtle.</span><span class="sig-name descname">onclick</span><span class="sig-paren">(</span><em class="sig-param"><span class="n">fun</span></em>, <em class="sig-param"><span class="n">btn</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">add</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span> +</dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>fun</strong> – a function with two arguments which will be called with the coordinates of the clicked point on the canvas</li> <li> +<strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li> <li> +<strong>add</strong> – <code>True</code> or <code>False</code> – if <code>True</code>, a new binding will be added, otherwise it will replace a former binding</li> </ul> </dd> </dl> <p>Bind <em>fun</em> to mouse-click events on this turtle. If <em>fun</em> is <code>None</code>, existing bindings are removed. Example for the anonymous turtle, i.e. the procedural way:</p> <pre data-language="pycon3">>>> def turn(x, y): +... left(180) +... +>>> onclick(turn) # Now clicking into the turtle will turn it. +>>> onclick(None) # event-binding will be removed +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.onrelease"> +<code>turtle.onrelease(fun, btn=1, add=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>fun</strong> – a function with two arguments which will be called with the coordinates of the clicked point on the canvas</li> <li> +<strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li> <li> +<strong>add</strong> – <code>True</code> or <code>False</code> – if <code>True</code>, a new binding will be added, otherwise it will replace a former binding</li> </ul> </dd> </dl> <p>Bind <em>fun</em> to mouse-button-release events on this turtle. If <em>fun</em> is <code>None</code>, existing bindings are removed.</p> <pre data-language="pycon3">>>> class MyTurtle(Turtle): +... def glow(self,x,y): +... self.fillcolor("red") +... def unglow(self,x,y): +... self.fillcolor("") +... +>>> turtle = MyTurtle() +>>> turtle.onclick(turtle.glow) # clicking on turtle turns fillcolor red, +>>> turtle.onrelease(turtle.unglow) # releasing turns it to transparent. +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.ondrag"> +<code>turtle.ondrag(fun, btn=1, add=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>fun</strong> – a function with two arguments which will be called with the coordinates of the clicked point on the canvas</li> <li> +<strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li> <li> +<strong>add</strong> – <code>True</code> or <code>False</code> – if <code>True</code>, a new binding will be added, otherwise it will replace a former binding</li> </ul> </dd> </dl> <p>Bind <em>fun</em> to mouse-move events on this turtle. If <em>fun</em> is <code>None</code>, existing bindings are removed.</p> <p>Remark: Every sequence of mouse-move-events on a turtle is preceded by a mouse-click event on that turtle.</p> <pre data-language="pycon3">>>> turtle.ondrag(turtle.goto) +</pre> <p>Subsequently, clicking and dragging the Turtle will move it across the screen thereby producing handdrawings (if pen is down).</p> </dd> +</dl> </section> <section id="special-turtle-methods"> <h3>Special Turtle methods</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.begin_poly"> +<code>turtle.begin_poly()</code> </dt> <dd> +<p>Start recording the vertices of a polygon. Current turtle position is first vertex of polygon.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.end_poly"> +<code>turtle.end_poly()</code> </dt> <dd> +<p>Stop recording the vertices of a polygon. Current turtle position is last vertex of polygon. This will be connected with the first vertex.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.get_poly"> +<code>turtle.get_poly()</code> </dt> <dd> +<p>Return the last recorded polygon.</p> <pre data-language="pycon3">>>> turtle.home() +>>> turtle.begin_poly() +>>> turtle.fd(100) +>>> turtle.left(20) +>>> turtle.fd(30) +>>> turtle.left(60) +>>> turtle.fd(50) +>>> turtle.end_poly() +>>> p = turtle.get_poly() +>>> register_shape("myFavouriteShape", p) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.clone"> +<code>turtle.clone()</code> </dt> <dd> +<p>Create and return a clone of the turtle with same position, heading and turtle properties.</p> <pre data-language="pycon3">>>> mick = Turtle() +>>> joe = mick.clone() +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.getturtle"> +<code>turtle.getturtle()</code> </dt> <dt class="sig sig-object py" id="turtle.getpen"> +<code>turtle.getpen()</code> </dt> <dd> +<p>Return the Turtle object itself. Only reasonable use: as a function to return the “anonymous turtle”:</p> <pre data-language="pycon3">>>> pet = getturtle() +>>> pet.fd(50) +>>> pet +<turtle.Turtle object at 0x...> +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.getscreen"> +<code>turtle.getscreen()</code> </dt> <dd> +<p>Return the <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code>TurtleScreen</code></a> object the turtle is drawing on. TurtleScreen methods can then be called for that object.</p> <pre data-language="pycon3">>>> ts = turtle.getscreen() +>>> ts +<turtle._Screen object at 0x...> +>>> ts.bgcolor("pink") +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.setundobuffer"> +<code>turtle.setundobuffer(size)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>size</strong> – an integer or <code>None</code></p> </dd> </dl> <p>Set or disable undobuffer. If <em>size</em> is an integer, an empty undobuffer of given size is installed. <em>size</em> gives the maximum number of turtle actions that can be undone by the <a class="reference internal" href="#turtle.undo" title="turtle.undo"><code>undo()</code></a> method/function. If <em>size</em> is <code>None</code>, the undobuffer is disabled.</p> <pre data-language="pycon3">>>> turtle.setundobuffer(42) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.undobufferentries"> +<code>turtle.undobufferentries()</code> </dt> <dd> +<p>Return number of entries in the undobuffer.</p> <pre data-language="pycon3">>>> while undobufferentries(): +... undo() +</pre> </dd> +</dl> </section> <section id="compound-shapes"> <span id="compoundshapes"></span><h3>Compound shapes</h3> <p>To use compound turtle shapes, which consist of several polygons of different color, you must use the helper class <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code>Shape</code></a> explicitly as described below:</p> <ol class="arabic"> <li>Create an empty Shape object of type “compound”.</li> <li> +<p>Add as many components to this object as desired, using the <a class="reference internal" href="#turtle.Shape.addcomponent" title="turtle.Shape.addcomponent"><code>addcomponent()</code></a> method.</p> <p>For example:</p> <pre data-language="pycon3">>>> s = Shape("compound") +>>> poly1 = ((0,0),(10,-5),(0,10),(-10,-5)) +>>> s.addcomponent(poly1, "red", "blue") +>>> poly2 = ((0,0),(10,-5),(-10,-5)) +>>> s.addcomponent(poly2, "blue", "red") +</pre> </li> <li> +<p>Now add the Shape to the Screen’s shapelist and use it:</p> <pre data-language="pycon3">>>> register_shape("myshape", s) +>>> shape("myshape") +</pre> </li> </ol> <div class="admonition note"> <p class="admonition-title">Note</p> <p>The <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code>Shape</code></a> class is used internally by the <a class="reference internal" href="#turtle.register_shape" title="turtle.register_shape"><code>register_shape()</code></a> method in different ways. The application programmer has to deal with the Shape class <em>only</em> when using compound shapes like shown above!</p> </div> </section> </section> <section id="methods-of-turtlescreen-screen-and-corresponding-functions"> <h2>Methods of TurtleScreen/Screen and corresponding functions</h2> <p>Most of the examples in this section refer to a TurtleScreen instance called <code>screen</code>.</p> <section id="window-control"> <h3>Window control</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.bgcolor"> +<code>turtle.bgcolor(*args)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>args</strong> – a color string or three numbers in the range 0..colormode or a 3-tuple of such numbers</p> </dd> </dl> <p>Set or return background color of the TurtleScreen.</p> <pre data-language="pycon3">>>> screen.bgcolor("orange") +>>> screen.bgcolor() +'orange' +>>> screen.bgcolor("#800080") +>>> screen.bgcolor() +(128.0, 0.0, 128.0) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.bgpic"> +<code>turtle.bgpic(picname=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>picname</strong> – a string, name of a gif-file or <code>"nopic"</code>, or <code>None</code></p> </dd> </dl> <p>Set background image or return name of current backgroundimage. If <em>picname</em> is a filename, set the corresponding image as background. If <em>picname</em> is <code>"nopic"</code>, delete background image, if present. If <em>picname</em> is <code>None</code>, return the filename of the current backgroundimage.</p> <pre data-language="python">>>> screen.bgpic() +'nopic' +>>> screen.bgpic("landscape.gif") +>>> screen.bgpic() +"landscape.gif" +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py"> <span class="sig-prename descclassname">turtle.</span><span class="sig-name descname">clear</span><span class="sig-paren">(</span><span class="sig-paren">)</span> +</dt> <dd> +<div class="admonition note"> <p class="admonition-title">Note</p> <p>This TurtleScreen method is available as a global function only under the name <code>clearscreen</code>. The global function <code>clear</code> is a different one derived from the Turtle method <code>clear</code>.</p> </div> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.clearscreen"> +<code>turtle.clearscreen()</code> </dt> <dd> +<p>Delete all drawings and all turtles from the TurtleScreen. Reset the now empty TurtleScreen to its initial state: white background, no background image, no event bindings and tracing on.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py"> <span class="sig-prename descclassname">turtle.</span><span class="sig-name descname">reset</span><span class="sig-paren">(</span><span class="sig-paren">)</span> +</dt> <dd> +<div class="admonition note"> <p class="admonition-title">Note</p> <p>This TurtleScreen method is available as a global function only under the name <code>resetscreen</code>. The global function <code>reset</code> is another one derived from the Turtle method <code>reset</code>.</p> </div> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.resetscreen"> +<code>turtle.resetscreen()</code> </dt> <dd> +<p>Reset all Turtles on the Screen to their initial state.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.screensize"> +<code>turtle.screensize(canvwidth=None, canvheight=None, bg=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>canvwidth</strong> – positive integer, new width of canvas in pixels</li> <li> +<strong>canvheight</strong> – positive integer, new height of canvas in pixels</li> <li> +<strong>bg</strong> – colorstring or color-tuple, new background color</li> </ul> </dd> </dl> <p>If no arguments are given, return current (canvaswidth, canvasheight). Else resize the canvas the turtles are drawing on. Do not alter the drawing window. To observe hidden parts of the canvas, use the scrollbars. With this method, one can make visible those parts of a drawing which were outside the canvas before.</p> <pre data-language="python">>>> screen.screensize() +(400, 300) +>>> screen.screensize(2000,1500) +>>> screen.screensize() +(2000, 1500) +</pre> <p>e.g. to search for an erroneously escaped turtle ;-)</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.setworldcoordinates"> +<code>turtle.setworldcoordinates(llx, lly, urx, ury)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>llx</strong> – a number, x-coordinate of lower left corner of canvas</li> <li> +<strong>lly</strong> – a number, y-coordinate of lower left corner of canvas</li> <li> +<strong>urx</strong> – a number, x-coordinate of upper right corner of canvas</li> <li> +<strong>ury</strong> – a number, y-coordinate of upper right corner of canvas</li> </ul> </dd> </dl> <p>Set up user-defined coordinate system and switch to mode “world” if necessary. This performs a <code>screen.reset()</code>. If mode “world” is already active, all drawings are redrawn according to the new coordinates.</p> <p><strong>ATTENTION</strong>: in user-defined coordinate systems angles may appear distorted.</p> <pre data-language="pycon3">>>> screen.reset() +>>> screen.setworldcoordinates(-50,-7.5,50,7.5) +>>> for _ in range(72): +... left(10) +... +>>> for _ in range(8): +... left(45); fd(2) # a regular octagon +</pre> </dd> +</dl> </section> <section id="animation-control"> <h3>Animation control</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.delay"> +<code>turtle.delay(delay=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>delay</strong> – positive integer</p> </dd> </dl> <p>Set or return the drawing <em>delay</em> in milliseconds. (This is approximately the time interval between two consecutive canvas updates.) The longer the drawing delay, the slower the animation.</p> <p>Optional argument:</p> <pre data-language="pycon3">>>> screen.delay() +10 +>>> screen.delay(5) +>>> screen.delay() +5 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.tracer"> +<code>turtle.tracer(n=None, delay=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>n</strong> – nonnegative integer</li> <li> +<strong>delay</strong> – nonnegative integer</li> </ul> </dd> </dl> <p>Turn turtle animation on/off and set delay for update drawings. If <em>n</em> is given, only each n-th regular screen update is really performed. (Can be used to accelerate the drawing of complex graphics.) When called without arguments, returns the currently stored value of n. Second argument sets delay value (see <a class="reference internal" href="#turtle.delay" title="turtle.delay"><code>delay()</code></a>).</p> <pre data-language="pycon3">>>> screen.tracer(8, 25) +>>> dist = 2 +>>> for i in range(200): +... fd(dist) +... rt(90) +... dist += 2 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.update"> +<code>turtle.update()</code> </dt> <dd> +<p>Perform a TurtleScreen update. To be used when tracer is turned off.</p> </dd> +</dl> <p>See also the RawTurtle/Turtle method <a class="reference internal" href="#turtle.speed" title="turtle.speed"><code>speed()</code></a>.</p> </section> <section id="using-screen-events"> <h3>Using screen events</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.listen"> +<code>turtle.listen(xdummy=None, ydummy=None)</code> </dt> <dd> +<p>Set focus on TurtleScreen (in order to collect key-events). Dummy arguments are provided in order to be able to pass <a class="reference internal" href="#turtle.listen" title="turtle.listen"><code>listen()</code></a> to the onclick method.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.onkey"> +<code>turtle.onkey(fun, key)</code> </dt> <dt class="sig sig-object py" id="turtle.onkeyrelease"> +<code>turtle.onkeyrelease(fun, key)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>fun</strong> – a function with no arguments or <code>None</code> +</li> <li> +<strong>key</strong> – a string: key (e.g. “a”) or key-symbol (e.g. “space”)</li> </ul> </dd> </dl> <p>Bind <em>fun</em> to key-release event of key. If <em>fun</em> is <code>None</code>, event bindings are removed. Remark: in order to be able to register key-events, TurtleScreen must have the focus. (See method <a class="reference internal" href="#turtle.listen" title="turtle.listen"><code>listen()</code></a>.)</p> <pre data-language="pycon3">>>> def f(): +... fd(50) +... lt(60) +... +>>> screen.onkey(f, "Up") +>>> screen.listen() +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.onkeypress"> +<code>turtle.onkeypress(fun, key=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>fun</strong> – a function with no arguments or <code>None</code> +</li> <li> +<strong>key</strong> – a string: key (e.g. “a”) or key-symbol (e.g. “space”)</li> </ul> </dd> </dl> <p>Bind <em>fun</em> to key-press event of key if key is given, or to any key-press-event if no key is given. Remark: in order to be able to register key-events, TurtleScreen must have focus. (See method <a class="reference internal" href="#turtle.listen" title="turtle.listen"><code>listen()</code></a>.)</p> <pre data-language="pycon3">>>> def f(): +... fd(50) +... +>>> screen.onkey(f, "Up") +>>> screen.listen() +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.onclick"> +<code>turtle.onclick(fun, btn=1, add=None)</code> </dt> <dt class="sig sig-object py" id="turtle.onscreenclick"> +<code>turtle.onscreenclick(fun, btn=1, add=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>fun</strong> – a function with two arguments which will be called with the coordinates of the clicked point on the canvas</li> <li> +<strong>btn</strong> – number of the mouse-button, defaults to 1 (left mouse button)</li> <li> +<strong>add</strong> – <code>True</code> or <code>False</code> – if <code>True</code>, a new binding will be added, otherwise it will replace a former binding</li> </ul> </dd> </dl> <p>Bind <em>fun</em> to mouse-click events on this screen. If <em>fun</em> is <code>None</code>, existing bindings are removed.</p> <p>Example for a TurtleScreen instance named <code>screen</code> and a Turtle instance named <code>turtle</code>:</p> <pre data-language="pycon3">>>> screen.onclick(turtle.goto) # Subsequently clicking into the TurtleScreen will +>>> # make the turtle move to the clicked point. +>>> screen.onclick(None) # remove event binding again +</pre> <div class="admonition note"> <p class="admonition-title">Note</p> <p>This TurtleScreen method is available as a global function only under the name <code>onscreenclick</code>. The global function <code>onclick</code> is another one derived from the Turtle method <code>onclick</code>.</p> </div> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.ontimer"> +<code>turtle.ontimer(fun, t=0)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>fun</strong> – a function with no arguments</li> <li> +<strong>t</strong> – a number >= 0</li> </ul> </dd> </dl> <p>Install a timer that calls <em>fun</em> after <em>t</em> milliseconds.</p> <pre data-language="pycon3">>>> running = True +>>> def f(): +... if running: +... fd(50) +... lt(60) +... screen.ontimer(f, 250) +>>> f() ### makes the turtle march around +>>> running = False +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.mainloop"> +<code>turtle.mainloop()</code> </dt> <dt class="sig sig-object py" id="turtle.done"> +<code>turtle.done()</code> </dt> <dd> +<p>Starts event loop - calling Tkinter’s mainloop function. Must be the last statement in a turtle graphics program. Must <em>not</em> be used if a script is run from within IDLE in -n mode (No subprocess) - for interactive use of turtle graphics.</p> <pre data-language="python">>>> screen.mainloop() +</pre> </dd> +</dl> </section> <section id="input-methods"> <h3>Input methods</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.textinput"> +<code>turtle.textinput(title, prompt)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>title</strong> – string</li> <li> +<strong>prompt</strong> – string</li> </ul> </dd> </dl> <p>Pop up a dialog window for input of a string. Parameter title is the title of the dialog window, prompt is a text mostly describing what information to input. Return the string input. If the dialog is canceled, return <code>None</code>.</p> <pre data-language="python">>>> screen.textinput("NIM", "Name of first player:") +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.numinput"> +<code>turtle.numinput(title, prompt, default=None, minval=None, maxval=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>title</strong> – string</li> <li> +<strong>prompt</strong> – string</li> <li> +<strong>default</strong> – number (optional)</li> <li> +<strong>minval</strong> – number (optional)</li> <li> +<strong>maxval</strong> – number (optional)</li> </ul> </dd> </dl> <p>Pop up a dialog window for input of a number. title is the title of the dialog window, prompt is a text mostly describing what numerical information to input. default: default value, minval: minimum value for input, maxval: maximum value for input. The number input must be in the range minval .. maxval if these are given. If not, a hint is issued and the dialog remains open for correction. Return the number input. If the dialog is canceled, return <code>None</code>.</p> <pre data-language="python">>>> screen.numinput("Poker", "Your stakes:", 1000, minval=10, maxval=10000) +</pre> </dd> +</dl> </section> <section id="settings-and-special-methods"> <h3>Settings and special methods</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.mode"> +<code>turtle.mode(mode=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>mode</strong> – one of the strings “standard”, “logo” or “world”</p> </dd> </dl> <p>Set turtle mode (“standard”, “logo” or “world”) and perform reset. If mode is not given, current mode is returned.</p> <p>Mode “standard” is compatible with old <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code>turtle</code></a>. Mode “logo” is compatible with most Logo turtle graphics. Mode “world” uses user-defined “world coordinates”. <strong>Attention</strong>: in this mode angles appear distorted if <code>x/y</code> unit-ratio doesn’t equal 1.</p> <table class="docutils align-default"> <thead> <tr> +<th class="head"><p>Mode</p></th> <th class="head"><p>Initial turtle heading</p></th> <th class="head"><p>positive angles</p></th> </tr> </thead> <tr> +<td><p>“standard”</p></td> <td><p>to the right (east)</p></td> <td><p>counterclockwise</p></td> </tr> <tr> +<td><p>“logo”</p></td> <td><p>upward (north)</p></td> <td><p>clockwise</p></td> </tr> </table> <pre data-language="pycon3">>>> mode("logo") # resets turtle heading to north +>>> mode() +'logo' +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.colormode"> +<code>turtle.colormode(cmode=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>cmode</strong> – one of the values 1.0 or 255</p> </dd> </dl> <p>Return the colormode or set it to 1.0 or 255. Subsequently <em>r</em>, <em>g</em>, <em>b</em> values of color triples have to be in the range 0..*cmode*.</p> <pre data-language="pycon3">>>> screen.colormode(1) +>>> turtle.pencolor(240, 160, 80) +Traceback (most recent call last): + ... +TurtleGraphicsError: bad color sequence: (240, 160, 80) +>>> screen.colormode() +1.0 +>>> screen.colormode(255) +>>> screen.colormode() +255 +>>> turtle.pencolor(240,160,80) +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.getcanvas"> +<code>turtle.getcanvas()</code> </dt> <dd> +<p>Return the Canvas of this TurtleScreen. Useful for insiders who know what to do with a Tkinter Canvas.</p> <pre data-language="pycon3">>>> cv = screen.getcanvas() +>>> cv +<turtle.ScrolledCanvas object ...> +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.getshapes"> +<code>turtle.getshapes()</code> </dt> <dd> +<p>Return a list of names of all currently available turtle shapes.</p> <pre data-language="pycon3">>>> screen.getshapes() +['arrow', 'blank', 'circle', ..., 'turtle'] +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.register_shape"> +<code>turtle.register_shape(name, shape=None)</code> </dt> <dt class="sig sig-object py" id="turtle.addshape"> +<code>turtle.addshape(name, shape=None)</code> </dt> <dd> +<p>There are three different ways to call this function:</p> <ol class="arabic"> <li> +<p><em>name</em> is the name of a gif-file and <em>shape</em> is <code>None</code>: Install the corresponding image shape.</p> <pre data-language="python">>>> screen.register_shape("turtle.gif") +</pre> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Image shapes <em>do not</em> rotate when turning the turtle, so they do not display the heading of the turtle!</p> </div> </li> <li> +<p><em>name</em> is an arbitrary string and <em>shape</em> is a tuple of pairs of coordinates: Install the corresponding polygon shape.</p> <pre data-language="pycon3">>>> screen.register_shape("triangle", ((5,-3), (0,5), (-5,-3))) +</pre> </li> <li> +<em>name</em> is an arbitrary string and <em>shape</em> is a (compound) <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code>Shape</code></a> object: Install the corresponding compound shape.</li> </ol> <p>Add a turtle shape to TurtleScreen’s shapelist. Only thusly registered shapes can be used by issuing the command <code>shape(shapename)</code>.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.turtles"> +<code>turtle.turtles()</code> </dt> <dd> +<p>Return the list of turtles on the screen.</p> <pre data-language="pycon3">>>> for turtle in screen.turtles(): +... turtle.color("red") +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.window_height"> +<code>turtle.window_height()</code> </dt> <dd> +<p>Return the height of the turtle window.</p> <pre data-language="python">>>> screen.window_height() +480 +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.window_width"> +<code>turtle.window_width()</code> </dt> <dd> +<p>Return the width of the turtle window.</p> <pre data-language="python">>>> screen.window_width() +640 +</pre> </dd> +</dl> </section> <section id="methods-specific-to-screen-not-inherited-from-turtlescreen"> <span id="screenspecific"></span><h3>Methods specific to Screen, not inherited from TurtleScreen</h3> <dl class="py function"> <dt class="sig sig-object py" id="turtle.bye"> +<code>turtle.bye()</code> </dt> <dd> +<p>Shut the turtlegraphics window.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.exitonclick"> +<code>turtle.exitonclick()</code> </dt> <dd> +<p>Bind <code>bye()</code> method to mouse clicks on the Screen.</p> <p>If the value “using_IDLE” in the configuration dictionary is <code>False</code> (default value), also enter mainloop. Remark: If IDLE with the <code>-n</code> switch (no subprocess) is used, this value should be set to <code>True</code> in <code>turtle.cfg</code>. In this case IDLE’s own mainloop is active also for the client script.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.setup"> +<code>turtle.setup(width=_CFG['width'], height=_CFG['height'], startx=_CFG['leftright'], starty=_CFG['topbottom'])</code> </dt> <dd> +<p>Set the size and position of the main window. Default values of arguments are stored in the configuration dictionary and can be changed via a <code>turtle.cfg</code> file.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>width</strong> – if an integer, a size in pixels, if a float, a fraction of the screen; default is 50% of screen</li> <li> +<strong>height</strong> – if an integer, the height in pixels, if a float, a fraction of the screen; default is 75% of screen</li> <li> +<strong>startx</strong> – if positive, starting position in pixels from the left edge of the screen, if negative from the right edge, if <code>None</code>, center window horizontally</li> <li> +<strong>starty</strong> – if positive, starting position in pixels from the top edge of the screen, if negative from the bottom edge, if <code>None</code>, center window vertically</li> </ul> </dd> </dl> <pre data-language="pycon3">>>> screen.setup (width=200, height=200, startx=0, starty=0) +>>> # sets window to 200x200 pixels, in upper left of screen +>>> screen.setup(width=.75, height=0.5, startx=None, starty=None) +>>> # sets window to 75% of screen by 50% of screen and centers +</pre> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="turtle.title"> +<code>turtle.title(titlestring)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>titlestring</strong> – a string that is shown in the titlebar of the turtle graphics window</p> </dd> </dl> <p>Set title of turtle window to <em>titlestring</em>.</p> <pre data-language="pycon3">>>> screen.title("Welcome to the turtle zoo!") +</pre> </dd> +</dl> </section> </section> <section id="public-classes"> <h2>Public classes</h2> <dl class="py class"> <dt class="sig sig-object py" id="turtle.RawTurtle"> +<code>class turtle.RawTurtle(canvas)</code> </dt> <dt class="sig sig-object py" id="turtle.RawPen"> +<code>class turtle.RawPen(canvas)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>canvas</strong> – a <code>tkinter.Canvas</code>, a <a class="reference internal" href="#turtle.ScrolledCanvas" title="turtle.ScrolledCanvas"><code>ScrolledCanvas</code></a> or a <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code>TurtleScreen</code></a></p> </dd> </dl> <p>Create a turtle. The turtle has all methods described above as “methods of Turtle/RawTurtle”.</p> </dd> +</dl> <dl class="py class"> <dt class="sig sig-object py" id="turtle.Turtle"> +<code>class turtle.Turtle</code> </dt> <dd> +<p>Subclass of RawTurtle, has the same interface but draws on a default <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a> object created automatically when needed for the first time.</p> </dd> +</dl> <dl class="py class"> <dt class="sig sig-object py" id="turtle.TurtleScreen"> +<code>class turtle.TurtleScreen(cv)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>cv</strong> – a <code>tkinter.Canvas</code></p> </dd> </dl> <p>Provides screen oriented methods like <a class="reference internal" href="#turtle.bgcolor" title="turtle.bgcolor"><code>bgcolor()</code></a> etc. that are described above.</p> </dd> +</dl> <dl class="py class"> <dt class="sig sig-object py" id="turtle.Screen"> +<code>class turtle.Screen</code> </dt> <dd> +<p>Subclass of TurtleScreen, with <a class="reference internal" href="#screenspecific"><span class="std std-ref">four methods added</span></a>.</p> </dd> +</dl> <dl class="py class"> <dt class="sig sig-object py" id="turtle.ScrolledCanvas"> +<code>class turtle.ScrolledCanvas(master)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>master</strong> – some Tkinter widget to contain the ScrolledCanvas, i.e. a Tkinter-canvas with scrollbars added</p> </dd> </dl> <p>Used by class Screen, which thus automatically provides a ScrolledCanvas as playground for the turtles.</p> </dd> +</dl> <dl class="py class"> <dt class="sig sig-object py" id="turtle.Shape"> +<code>class turtle.Shape(type_, data)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>type_</strong> – one of the strings “polygon”, “image”, “compound”</p> </dd> </dl> <p>Data structure modeling shapes. The pair <code>(type_, data)</code> must follow this specification:</p> <table class="docutils align-default"> <thead> <tr> +<th class="head"><p><em>type_</em></p></th> <th class="head"><p><em>data</em></p></th> </tr> </thead> <tr> +<td><p>“polygon”</p></td> <td><p>a polygon-tuple, i.e. a tuple of pairs of coordinates</p></td> </tr> <tr> +<td><p>“image”</p></td> <td><p>an image (in this form only used internally!)</p></td> </tr> <tr> +<td><p>“compound”</p></td> <td><p><code>None</code> (a compound shape has to be constructed using the <a class="reference internal" href="#turtle.Shape.addcomponent" title="turtle.Shape.addcomponent"><code>addcomponent()</code></a> method)</p></td> </tr> </table> <dl class="py method"> <dt class="sig sig-object py" id="turtle.Shape.addcomponent"> +<code>addcomponent(poly, fill, outline=None)</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<ul class="simple"> <li> +<strong>poly</strong> – a polygon, i.e. a tuple of pairs of numbers</li> <li> +<strong>fill</strong> – a color the <em>poly</em> will be filled with</li> <li> +<strong>outline</strong> – a color for the poly’s outline (if given)</li> </ul> </dd> </dl> <p>Example:</p> <pre data-language="pycon3">>>> poly = ((0,0),(10,-5),(0,10),(-10,-5)) +>>> s = Shape("compound") +>>> s.addcomponent(poly, "red", "blue") +>>> # ... add more components and then use register_shape() +</pre> <p>See <a class="reference internal" href="#compoundshapes"><span class="std std-ref">Compound shapes</span></a>.</p> </dd> +</dl> </dd> +</dl> <dl class="py class"> <dt class="sig sig-object py" id="turtle.Vec2D"> +<code>class turtle.Vec2D(x, y)</code> </dt> <dd> +<p>A two-dimensional vector class, used as a helper class for implementing turtle graphics. May be useful for turtle graphics programs too. Derived from tuple, so a vector is a tuple!</p> <p>Provides (for <em>a</em>, <em>b</em> vectors, <em>k</em> number):</p> <ul class="simple"> <li> +<code>a + b</code> vector addition</li> <li> +<code>a - b</code> vector subtraction</li> <li> +<code>a * b</code> inner product</li> <li> +<code>k * a</code> and <code>a * k</code> multiplication with scalar</li> <li> +<code>abs(a)</code> absolute value of a</li> <li> +<code>a.rotate(angle)</code> rotation</li> </ul> </dd> +</dl> </section> <section id="explanation"> <span id="turtle-explanation"></span><h2>Explanation</h2> <p>A turtle object draws on a screen object, and there a number of key classes in the turtle object-oriented interface that can be used to create them and relate them to each other.</p> <p>A <a class="reference internal" href="#turtle.Turtle" title="turtle.Turtle"><code>Turtle</code></a> instance will automatically create a <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a> instance if one is not already present.</p> <p><code>Turtle</code> is a subclass of <a class="reference internal" href="#turtle.RawTurtle" title="turtle.RawTurtle"><code>RawTurtle</code></a>, which <em>doesn’t</em> automatically create a drawing surface - a <em>canvas</em> will need to be provided or created for it. The <em>canvas</em> can be a <code>tkinter.Canvas</code>, <a class="reference internal" href="#turtle.ScrolledCanvas" title="turtle.ScrolledCanvas"><code>ScrolledCanvas</code></a> or <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code>TurtleScreen</code></a>.</p> <p><a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code>TurtleScreen</code></a> is the basic drawing surface for a turtle. <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a> is a subclass of <code>TurtleScreen</code>, and includes <a class="reference internal" href="#screenspecific"><span class="std std-ref">some additional methods</span></a> for managing its appearance (including size and title) and behaviour. <code>TurtleScreen</code>’s constructor needs a <code>tkinter.Canvas</code> or a <a class="reference internal" href="#turtle.ScrolledCanvas" title="turtle.ScrolledCanvas"><code>ScrolledCanvas</code></a> as an argument.</p> <p>The functional interface for turtle graphics uses the various methods of <code>Turtle</code> and <code>TurtleScreen</code>/<code>Screen</code>. Behind the scenes, a screen object is automatically created whenever a function derived from a <code>Screen</code> method is called. Similarly, a turtle object is automatically created whenever any of the functions derived from a Turtle method is called.</p> <p>To use multiple turtles on a screen, the object-oriented interface must be used.</p> </section> <section id="help-and-configuration"> <h2>Help and configuration</h2> <section id="how-to-use-help"> <h3>How to use help</h3> <p>The public methods of the Screen and Turtle classes are documented extensively via docstrings. So these can be used as online-help via the Python help facilities:</p> <ul> <li>When using IDLE, tooltips show the signatures and first lines of the docstrings of typed in function-/method calls.</li> <li> +<p>Calling <a class="reference internal" href="functions#help" title="help"><code>help()</code></a> on methods or functions displays the docstrings:</p> <pre data-language="python">>>> help(Screen.bgcolor) +Help on method bgcolor in module turtle: + +bgcolor(self, *args) unbound turtle.Screen method + Set or return backgroundcolor of the TurtleScreen. + + Arguments (if given): a color string or three numbers + in the range 0..colormode or a 3-tuple of such numbers. + + + >>> screen.bgcolor("orange") + >>> screen.bgcolor() + "orange" + >>> screen.bgcolor(0.5,0,0.5) + >>> screen.bgcolor() + "#800080" + +>>> help(Turtle.penup) +Help on method penup in module turtle: + +penup(self) unbound turtle.Turtle method + Pull the pen up -- no drawing when moving. + + Aliases: penup | pu | up + + No argument + + >>> turtle.penup() +</pre> </li> <li> +<p>The docstrings of the functions which are derived from methods have a modified form:</p> <pre data-language="python">>>> help(bgcolor) +Help on function bgcolor in module turtle: + +bgcolor(*args) + Set or return backgroundcolor of the TurtleScreen. + + Arguments (if given): a color string or three numbers + in the range 0..colormode or a 3-tuple of such numbers. + + Example:: + + >>> bgcolor("orange") + >>> bgcolor() + "orange" + >>> bgcolor(0.5,0,0.5) + >>> bgcolor() + "#800080" + +>>> help(penup) +Help on function penup in module turtle: + +penup() + Pull the pen up -- no drawing when moving. + + Aliases: penup | pu | up + + No argument + + Example: + >>> penup() +</pre> </li> </ul> <p>These modified docstrings are created automatically together with the function definitions that are derived from the methods at import time.</p> </section> <section id="translation-of-docstrings-into-different-languages"> <h3>Translation of docstrings into different languages</h3> <p>There is a utility to create a dictionary the keys of which are the method names and the values of which are the docstrings of the public methods of the classes Screen and Turtle.</p> <dl class="py function"> <dt class="sig sig-object py" id="turtle.write_docstringdict"> +<code>turtle.write_docstringdict(filename='turtle_docstringdict')</code> </dt> <dd> +<dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"> +<p><strong>filename</strong> – a string, used as filename</p> </dd> </dl> <p>Create and write docstring-dictionary to a Python script with the given filename. This function has to be called explicitly (it is not used by the turtle graphics classes). The docstring dictionary will be written to the Python script <code><em>filename</em>.py</code>. It is intended to serve as a template for translation of the docstrings into different languages.</p> </dd> +</dl> <p>If you (or your students) want to use <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code>turtle</code></a> with online help in your native language, you have to translate the docstrings and save the resulting file as e.g. <code>turtle_docstringdict_german.py</code>.</p> <p>If you have an appropriate entry in your <code>turtle.cfg</code> file this dictionary will be read in at import time and will replace the original English docstrings.</p> <p>At the time of this writing there are docstring dictionaries in German and in Italian. (Requests please to <a class="reference external" href="mailto:glingl%40aon.at">glingl<span>@</span>aon<span>.</span>at</a>.)</p> </section> <section id="how-to-configure-screen-and-turtles"> <h3>How to configure Screen and Turtles</h3> <p>The built-in default configuration mimics the appearance and behaviour of the old turtle module in order to retain best possible compatibility with it.</p> <p>If you want to use a different configuration which better reflects the features of this module or which better fits to your needs, e.g. for use in a classroom, you can prepare a configuration file <code>turtle.cfg</code> which will be read at import time and modify the configuration according to its settings.</p> <p>The built in configuration would correspond to the following <code>turtle.cfg</code>:</p> <pre data-language="ini">width = 0.5 +height = 0.75 +leftright = None +topbottom = None +canvwidth = 400 +canvheight = 300 +mode = standard +colormode = 1.0 +delay = 10 +undobuffersize = 1000 +shape = classic +pencolor = black +fillcolor = black +resizemode = noresize +visible = True +language = english +exampleturtle = turtle +examplescreen = screen +title = Python Turtle Graphics +using_IDLE = False +</pre> <p>Short explanation of selected entries:</p> <ul class="simple"> <li>The first four lines correspond to the arguments of the <a class="reference internal" href="#turtle.setup" title="turtle.setup"><code>Screen.setup</code></a> method.</li> <li>Line 5 and 6 correspond to the arguments of the method <a class="reference internal" href="#turtle.screensize" title="turtle.screensize"><code>Screen.screensize</code></a>.</li> <li> +<em>shape</em> can be any of the built-in shapes, e.g: arrow, turtle, etc. For more info try <code>help(shape)</code>.</li> <li>If you want to use no fill color (i.e. make the turtle transparent), you have to write <code>fillcolor = ""</code> (but all nonempty strings must not have quotes in the cfg file).</li> <li>If you want to reflect the turtle its state, you have to use <code>resizemode = +auto</code>.</li> <li>If you set e.g. <code>language = italian</code> the docstringdict <code>turtle_docstringdict_italian.py</code> will be loaded at import time (if present on the import path, e.g. in the same directory as <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code>turtle</code></a>).</li> <li>The entries <em>exampleturtle</em> and <em>examplescreen</em> define the names of these objects as they occur in the docstrings. The transformation of method-docstrings to function-docstrings will delete these names from the docstrings.</li> <li> +<em>using_IDLE</em>: Set this to <code>True</code> if you regularly work with IDLE and its <code>-n</code> switch (“no subprocess”). This will prevent <a class="reference internal" href="#turtle.exitonclick" title="turtle.exitonclick"><code>exitonclick()</code></a> to enter the mainloop.</li> </ul> <p>There can be a <code>turtle.cfg</code> file in the directory where <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code>turtle</code></a> is stored and an additional one in the current working directory. The latter will override the settings of the first one.</p> <p>The <code>Lib/turtledemo</code> directory contains a <code>turtle.cfg</code> file. You can study it as an example and see its effects when running the demos (preferably not from within the demo-viewer).</p> </section> </section> <section id="module-turtledemo"> <span id="turtledemo-demo-scripts"></span><h2>turtledemo — Demo scripts</h2> <p>The <a class="reference internal" href="#module-turtledemo" title="turtledemo: A viewer for example turtle scripts"><code>turtledemo</code></a> package includes a set of demo scripts. These scripts can be run and viewed using the supplied demo viewer as follows:</p> <pre data-language="python">python -m turtledemo +</pre> <p>Alternatively, you can run the demo scripts individually. For example,</p> <pre data-language="python">python -m turtledemo.bytedesign +</pre> <p>The <a class="reference internal" href="#module-turtledemo" title="turtledemo: A viewer for example turtle scripts"><code>turtledemo</code></a> package directory contains:</p> <ul class="simple"> <li>A demo viewer <code>__main__.py</code> which can be used to view the sourcecode of the scripts and run them at the same time.</li> <li>Multiple scripts demonstrating different features of the <a class="reference internal" href="#module-turtle" title="turtle: An educational framework for simple graphics applications"><code>turtle</code></a> module. Examples can be accessed via the Examples menu. They can also be run standalone.</li> <li>A <code>turtle.cfg</code> file which serves as an example of how to write and use such files.</li> </ul> <p>The demo scripts are:</p> <table class="docutils align-default"> <thead> <tr> +<th class="head"><p>Name</p></th> <th class="head"><p>Description</p></th> <th class="head"><p>Features</p></th> </tr> </thead> <tr> +<td><p>bytedesign</p></td> <td><p>complex classical turtle graphics pattern</p></td> <td><p><a class="reference internal" href="#turtle.tracer" title="turtle.tracer"><code>tracer()</code></a>, delay, <a class="reference internal" href="#turtle.update" title="turtle.update"><code>update()</code></a></p></td> </tr> <tr> +<td><p>chaos</p></td> <td><p>graphs Verhulst dynamics, shows that computer’s computations can generate results sometimes against the common sense expectations</p></td> <td><p>world coordinates</p></td> </tr> <tr> +<td><p>clock</p></td> <td><p>analog clock showing time of your computer</p></td> <td><p>turtles as clock’s hands, ontimer</p></td> </tr> <tr> +<td><p>colormixer</p></td> <td><p>experiment with r, g, b</p></td> <td><p><a class="reference internal" href="#turtle.ondrag" title="turtle.ondrag"><code>ondrag()</code></a></p></td> </tr> <tr> +<td><p>forest</p></td> <td><p>3 breadth-first trees</p></td> <td><p>randomization</p></td> </tr> <tr> +<td><p>fractalcurves</p></td> <td><p>Hilbert & Koch curves</p></td> <td><p>recursion</p></td> </tr> <tr> +<td><p>lindenmayer</p></td> <td><p>ethnomathematics (indian kolams)</p></td> <td><p>L-System</p></td> </tr> <tr> +<td><p>minimal_hanoi</p></td> <td><p>Towers of Hanoi</p></td> <td><p>Rectangular Turtles as Hanoi discs (shape, shapesize)</p></td> </tr> <tr> +<td><p>nim</p></td> <td><p>play the classical nim game with three heaps of sticks against the computer.</p></td> <td><p>turtles as nimsticks, event driven (mouse, keyboard)</p></td> </tr> <tr> +<td><p>paint</p></td> <td><p>super minimalistic drawing program</p></td> <td><p><a class="reference internal" href="#turtle.onclick" title="turtle.onclick"><code>onclick()</code></a></p></td> </tr> <tr> +<td><p>peace</p></td> <td><p>elementary</p></td> <td><p>turtle: appearance and animation</p></td> </tr> <tr> +<td><p>penrose</p></td> <td><p>aperiodic tiling with kites and darts</p></td> <td><p><a class="reference internal" href="#turtle.stamp" title="turtle.stamp"><code>stamp()</code></a></p></td> </tr> <tr> +<td><p>planet_and_moon</p></td> <td><p>simulation of gravitational system</p></td> <td><p>compound shapes, <a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code>Vec2D</code></a></p></td> </tr> <tr> +<td><p>rosette</p></td> <td><p>a pattern from the wikipedia article on turtle graphics</p></td> <td><p><a class="reference internal" href="#turtle.clone" title="turtle.clone"><code>clone()</code></a>, <a class="reference internal" href="#turtle.undo" title="turtle.undo"><code>undo()</code></a></p></td> </tr> <tr> +<td><p>round_dance</p></td> <td><p>dancing turtles rotating pairwise in opposite direction</p></td> <td><p>compound shapes, clone shapesize, tilt, get_shapepoly, update</p></td> </tr> <tr> +<td><p>sorting_animate</p></td> <td><p>visual demonstration of different sorting methods</p></td> <td><p>simple alignment, randomization</p></td> </tr> <tr> +<td><p>tree</p></td> <td><p>a (graphical) breadth first tree (using generators)</p></td> <td><p><a class="reference internal" href="#turtle.clone" title="turtle.clone"><code>clone()</code></a></p></td> </tr> <tr> +<td><p>two_canvases</p></td> <td><p>simple design</p></td> <td><p>turtles on two canvases</p></td> </tr> <tr> +<td><p>yinyang</p></td> <td><p>another elementary example</p></td> <td><p><a class="reference internal" href="#turtle.circle" title="turtle.circle"><code>circle()</code></a></p></td> </tr> </table> <p>Have fun!</p> </section> <section id="changes-since-python-2-6"> <h2>Changes since Python 2.6</h2> <ul class="simple"> <li>The methods <a class="reference internal" href="#turtle.tracer" title="turtle.tracer"><code>Turtle.tracer</code></a>, <a class="reference internal" href="#turtle.window_width" title="turtle.window_width"><code>Turtle.window_width</code></a> and <a class="reference internal" href="#turtle.window_height" title="turtle.window_height"><code>Turtle.window_height</code></a> have been eliminated. Methods with these names and functionality are now available only as methods of <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a>. The functions derived from these remain available. (In fact already in Python 2.6 these methods were merely duplications of the corresponding <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code>TurtleScreen</code></a>/<a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a> methods.)</li> <li>The method <code>Turtle.fill()</code> has been eliminated. The behaviour of <a class="reference internal" href="#turtle.begin_fill" title="turtle.begin_fill"><code>begin_fill()</code></a> and <a class="reference internal" href="#turtle.end_fill" title="turtle.end_fill"><code>end_fill()</code></a> have changed slightly: now every filling process must be completed with an <code>end_fill()</code> call.</li> <li>A method <a class="reference internal" href="#turtle.filling" title="turtle.filling"><code>Turtle.filling</code></a> has been added. It returns a boolean value: <code>True</code> if a filling process is under way, <code>False</code> otherwise. This behaviour corresponds to a <code>fill()</code> call without arguments in Python 2.6.</li> </ul> </section> <section id="changes-since-python-3-0"> <h2>Changes since Python 3.0</h2> <ul class="simple"> <li>The <a class="reference internal" href="#turtle.Turtle" title="turtle.Turtle"><code>Turtle</code></a> methods <a class="reference internal" href="#turtle.shearfactor" title="turtle.shearfactor"><code>shearfactor()</code></a>, <a class="reference internal" href="#turtle.shapetransform" title="turtle.shapetransform"><code>shapetransform()</code></a> and <a class="reference internal" href="#turtle.get_shapepoly" title="turtle.get_shapepoly"><code>get_shapepoly()</code></a> have been added. Thus the full range of regular linear transforms is now available for transforming turtle shapes. <a class="reference internal" href="#turtle.tiltangle" title="turtle.tiltangle"><code>tiltangle()</code></a> has been enhanced in functionality: it now can be used to get or set the tilt angle. <a class="reference internal" href="#turtle.settiltangle" title="turtle.settiltangle"><code>settiltangle()</code></a> has been deprecated.</li> <li>The <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a> method <a class="reference internal" href="#turtle.onkeypress" title="turtle.onkeypress"><code>onkeypress()</code></a> has been added as a complement to <a class="reference internal" href="#turtle.onkey" title="turtle.onkey"><code>onkey()</code></a>. As the latter binds actions to the key release event, an alias: <a class="reference internal" href="#turtle.onkeyrelease" title="turtle.onkeyrelease"><code>onkeyrelease()</code></a> was also added for it.</li> <li>The method <a class="reference internal" href="#turtle.mainloop" title="turtle.mainloop"><code>Screen.mainloop</code></a> has been added, so there is no longer a need to use the standalone <a class="reference internal" href="#turtle.mainloop" title="turtle.mainloop"><code>mainloop()</code></a> function when working with <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code>Screen</code></a> and <a class="reference internal" href="#turtle.Turtle" title="turtle.Turtle"><code>Turtle</code></a> objects.</li> <li>Two input methods have been added: <a class="reference internal" href="#turtle.textinput" title="turtle.textinput"><code>Screen.textinput</code></a> and <a class="reference internal" href="#turtle.numinput" title="turtle.numinput"><code>Screen.numinput</code></a>. These pop up input dialogs and return strings and numbers respectively.</li> <li>Two example scripts <code>tdemo_nim.py</code> and <code>tdemo_round_dance.py</code> have been added to the <code>Lib/turtledemo</code> directory.</li> </ul> </section> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/library/turtle.html" class="_attribution-link">https://docs.python.org/3.12/library/turtle.html</a> + </p> +</div> |
