Kerala Cyber Warriors
KCW Uploader V1.1

Path : /usr/share/doc/python2/html/library/
File Upload :
Current File : //usr/share/doc/python2/html/library/turtle.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>24.5. turtle — Turtle graphics for Tk &#8212; Python 2.7.18 documentation</title>
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 2.7.18 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="24.6. IDLE" href="idle.html" />
    <link rel="prev" title="24.4. ScrolledText — Scrolled Text Widget" href="scrolledtext.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="file:///usr/share/doc/python2.7/html/library/turtle.html" />
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
 
    

  </head><body>
<div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;">
    This document is for an old version of Python that is <a href="https://devguide.python.org/devcycle/#end-of-life-branches">no longer supported</a>.
    You should install the python3 and python3-doc packages and read the 
    <a href="file:///usr/share/doc/python3-doc/html/library/turtle.html"> Python documentation for the Python3 version packaged in this release</a>.
</div>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="idle.html" title="24.6. IDLE"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="scrolledtext.html" title="24.4. ScrolledText — Scrolled Text Widget"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">Python 2.7.18 documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">24. Graphical User Interfaces with Tk</a> &#187;</li> 
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-turtle">
<span id="turtle-turtle-graphics-for-tk"></span><h1>24.5. <a class="reference internal" href="#module-turtle" title="turtle: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> — Turtle graphics for Tk<a class="headerlink" href="#module-turtle" title="Permalink to this headline">¶</a></h1>
<div class="section" id="introduction">
<h2>24.5.1. Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Turtle graphics is a popular way for introducing programming to kids.  It was
part of the original Logo programming language developed by Wally Feurzig and
Seymour Papert in 1966.</p>
<p>Imagine a robotic turtle starting at (0, 0) in the x-y plane.  After an <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">turtle</span></code>, give it the
command <code class="docutils literal notranslate"><span class="pre">turtle.forward(15)</span></code>, and it moves (on-screen!) 15 pixels in the
direction it is facing, drawing a line as it moves.  Give it the command
<code class="docutils literal notranslate"><span class="pre">turtle.right(25)</span></code>, and it rotates in-place 25 degrees clockwise.</p>
<p>By combining together these and similar commands, intricate shapes and pictures
can easily be drawn.</p>
<p>The <a class="reference internal" href="#module-turtle" title="turtle: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> module is an extended reimplementation of the same-named
module from the Python standard distribution up to version Python 2.5.</p>
<p>It tries to keep the merits of the old turtle module and to be (nearly) 100%
compatible with it.  This means in the first place to enable the learning
programmer to use all the commands, classes and methods interactively when using
the module from within IDLE run with the <code class="docutils literal notranslate"><span class="pre">-n</span></code> switch.</p>
<p>The turtle module provides turtle graphics primitives, in both object-oriented
and procedure-oriented ways.  Because it uses <a class="reference internal" href="tkinter.html#module-Tkinter" title="Tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">Tkinter</span></code></a> for the underlying
graphics, it needs a version of Python installed with Tk support.</p>
<p>The object-oriented interface uses essentially two+two classes:</p>
<ol class="arabic">
<li><p class="first">The <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a> class defines graphics windows as a playground for
the drawing turtles.  Its constructor needs a <code class="xref py py-class docutils literal notranslate"><span class="pre">Tkinter.Canvas</span></code> or a
<a class="reference internal" href="#turtle.ScrolledCanvas" title="turtle.ScrolledCanvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">ScrolledCanvas</span></code></a> as argument.  It should be used when <a class="reference internal" href="#module-turtle" title="turtle: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> is
used as part of some application.</p>
<p>The function <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code class="xref py py-func docutils literal notranslate"><span class="pre">Screen()</span></code></a> returns a singleton object of a
<a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a> subclass. This function should be used when
<a class="reference internal" href="#module-turtle" title="turtle: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> is used as a standalone tool for doing graphics.
As a singleton object, inheriting from its class is not possible.</p>
<p>All methods of TurtleScreen/Screen also exist as functions, i.e. as part of
the procedure-oriented interface.</p>
</li>
<li><p class="first"><a class="reference internal" href="#turtle.RawTurtle" title="turtle.RawTurtle"><code class="xref py py-class docutils literal notranslate"><span class="pre">RawTurtle</span></code></a> (alias: <a class="reference internal" href="#turtle.RawPen" title="turtle.RawPen"><code class="xref py py-class docutils literal notranslate"><span class="pre">RawPen</span></code></a>) defines Turtle objects which draw
on a <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a>.  Its constructor needs a Canvas, ScrolledCanvas
or TurtleScreen as argument, so the RawTurtle objects know where to draw.</p>
<p>Derived from RawTurtle is the subclass <a class="reference internal" href="#turtle.Turtle" title="turtle.Turtle"><code class="xref py py-class docutils literal notranslate"><span class="pre">Turtle</span></code></a> (alias: <code class="xref py py-class docutils literal notranslate"><span class="pre">Pen</span></code>),
which draws on “the” <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code></a> - instance which is automatically
created, if not already present.</p>
<p>All methods of RawTurtle/Turtle also exist as functions, i.e. part of the
procedure-oriented interface.</p>
</li>
</ol>
<p>The procedural interface provides functions which are derived from the methods
of the classes <a class="reference internal" href="#turtle.Screen" title="turtle.Screen"><code class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code></a> and <a class="reference internal" href="#turtle.Turtle" title="turtle.Turtle"><code class="xref py py-class docutils literal notranslate"><span class="pre">Turtle</span></code></a>.  They have the same names as
the corresponding methods.  A screen object is automatically created whenever a
function derived from a Screen method is called.  An (unnamed) turtle object is
automatically created whenever any of the functions derived from a Turtle method
is called.</p>
<p>To use multiple turtles an a screen one has to use the object-oriented interface.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">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>
</div>
<div class="section" id="overview-over-available-turtle-and-screen-methods">
<h2>24.5.2. Overview over available Turtle and Screen methods<a class="headerlink" href="#overview-over-available-turtle-and-screen-methods" title="Permalink to this headline">¶</a></h2>
<div class="section" id="turtle-methods">
<h3>24.5.2.1. Turtle methods<a class="headerlink" href="#turtle-methods" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt>Turtle motion</dt>
<dd><dl class="first last docutils">
<dt>Move and draw</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.forward" title="turtle.forward"><code class="xref py py-func docutils literal notranslate"><span class="pre">forward()</span></code></a> | <a class="reference internal" href="#turtle.fd" title="turtle.fd"><code class="xref py py-func docutils literal notranslate"><span class="pre">fd()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.backward" title="turtle.backward"><code class="xref py py-func docutils literal notranslate"><span class="pre">backward()</span></code></a> | <a class="reference internal" href="#turtle.bk" title="turtle.bk"><code class="xref py py-func docutils literal notranslate"><span class="pre">bk()</span></code></a> | <a class="reference internal" href="#turtle.back" title="turtle.back"><code class="xref py py-func docutils literal notranslate"><span class="pre">back()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.right" title="turtle.right"><code class="xref py py-func docutils literal notranslate"><span class="pre">right()</span></code></a> | <a class="reference internal" href="#turtle.rt" title="turtle.rt"><code class="xref py py-func docutils literal notranslate"><span class="pre">rt()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.left" title="turtle.left"><code class="xref py py-func docutils literal notranslate"><span class="pre">left()</span></code></a> | <a class="reference internal" href="#turtle.lt" title="turtle.lt"><code class="xref py py-func docutils literal notranslate"><span class="pre">lt()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.goto" title="turtle.goto"><code class="xref py py-func docutils literal notranslate"><span class="pre">goto()</span></code></a> | <a class="reference internal" href="#turtle.setpos" title="turtle.setpos"><code class="xref py py-func docutils literal notranslate"><span class="pre">setpos()</span></code></a> | <a class="reference internal" href="#turtle.setposition" title="turtle.setposition"><code class="xref py py-func docutils literal notranslate"><span class="pre">setposition()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setx" title="turtle.setx"><code class="xref py py-func docutils literal notranslate"><span class="pre">setx()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.sety" title="turtle.sety"><code class="xref py py-func docutils literal notranslate"><span class="pre">sety()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setheading" title="turtle.setheading"><code class="xref py py-func docutils literal notranslate"><span class="pre">setheading()</span></code></a> | <a class="reference internal" href="#turtle.seth" title="turtle.seth"><code class="xref py py-func docutils literal notranslate"><span class="pre">seth()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.home" title="turtle.home"><code class="xref py py-func docutils literal notranslate"><span class="pre">home()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.circle" title="turtle.circle"><code class="xref py py-func docutils literal notranslate"><span class="pre">circle()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.dot" title="turtle.dot"><code class="xref py py-func docutils literal notranslate"><span class="pre">dot()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.stamp" title="turtle.stamp"><code class="xref py py-func docutils literal notranslate"><span class="pre">stamp()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clearstamp" title="turtle.clearstamp"><code class="xref py py-func docutils literal notranslate"><span class="pre">clearstamp()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clearstamps" title="turtle.clearstamps"><code class="xref py py-func docutils literal notranslate"><span class="pre">clearstamps()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.undo" title="turtle.undo"><code class="xref py py-func docutils literal notranslate"><span class="pre">undo()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.speed" title="turtle.speed"><code class="xref py py-func docutils literal notranslate"><span class="pre">speed()</span></code></a></div>
</div>
</dd>
<dt>Tell Turtle’s state</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.position" title="turtle.position"><code class="xref py py-func docutils literal notranslate"><span class="pre">position()</span></code></a> | <a class="reference internal" href="#turtle.pos" title="turtle.pos"><code class="xref py py-func docutils literal notranslate"><span class="pre">pos()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.towards" title="turtle.towards"><code class="xref py py-func docutils literal notranslate"><span class="pre">towards()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.xcor" title="turtle.xcor"><code class="xref py py-func docutils literal notranslate"><span class="pre">xcor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.ycor" title="turtle.ycor"><code class="xref py py-func docutils literal notranslate"><span class="pre">ycor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.heading" title="turtle.heading"><code class="xref py py-func docutils literal notranslate"><span class="pre">heading()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.distance" title="turtle.distance"><code class="xref py py-func docutils literal notranslate"><span class="pre">distance()</span></code></a></div>
</div>
</dd>
<dt>Setting and measurement</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.degrees" title="turtle.degrees"><code class="xref py py-func docutils literal notranslate"><span class="pre">degrees()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.radians" title="turtle.radians"><code class="xref py py-func docutils literal notranslate"><span class="pre">radians()</span></code></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Pen control</dt>
<dd><dl class="first last docutils">
<dt>Drawing state</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.pendown" title="turtle.pendown"><code class="xref py py-func docutils literal notranslate"><span class="pre">pendown()</span></code></a> | <a class="reference internal" href="#turtle.pd" title="turtle.pd"><code class="xref py py-func docutils literal notranslate"><span class="pre">pd()</span></code></a> | <a class="reference internal" href="#turtle.down" title="turtle.down"><code class="xref py py-func docutils literal notranslate"><span class="pre">down()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.penup" title="turtle.penup"><code class="xref py py-func docutils literal notranslate"><span class="pre">penup()</span></code></a> | <a class="reference internal" href="#turtle.pu" title="turtle.pu"><code class="xref py py-func docutils literal notranslate"><span class="pre">pu()</span></code></a> | <a class="reference internal" href="#turtle.up" title="turtle.up"><code class="xref py py-func docutils literal notranslate"><span class="pre">up()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.pensize" title="turtle.pensize"><code class="xref py py-func docutils literal notranslate"><span class="pre">pensize()</span></code></a> | <a class="reference internal" href="#turtle.width" title="turtle.width"><code class="xref py py-func docutils literal notranslate"><span class="pre">width()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.pen" title="turtle.pen"><code class="xref py py-func docutils literal notranslate"><span class="pre">pen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.isdown" title="turtle.isdown"><code class="xref py py-func docutils literal notranslate"><span class="pre">isdown()</span></code></a></div>
</div>
</dd>
<dt>Color control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.color" title="turtle.color"><code class="xref py py-func docutils literal notranslate"><span class="pre">color()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.pencolor" title="turtle.pencolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">pencolor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.fillcolor" title="turtle.fillcolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">fillcolor()</span></code></a></div>
</div>
</dd>
<dt>Filling</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.fill" title="turtle.fill"><code class="xref py py-func docutils literal notranslate"><span class="pre">fill()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.begin_fill" title="turtle.begin_fill"><code class="xref py py-func docutils literal notranslate"><span class="pre">begin_fill()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.end_fill" title="turtle.end_fill"><code class="xref py py-func docutils literal notranslate"><span class="pre">end_fill()</span></code></a></div>
</div>
</dd>
<dt>More drawing control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.reset" title="turtle.reset"><code class="xref py py-func docutils literal notranslate"><span class="pre">reset()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clear" title="turtle.clear"><code class="xref py py-func docutils literal notranslate"><span class="pre">clear()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.write" title="turtle.write"><code class="xref py py-func docutils literal notranslate"><span class="pre">write()</span></code></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Turtle state</dt>
<dd><dl class="first last docutils">
<dt>Visibility</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.showturtle" title="turtle.showturtle"><code class="xref py py-func docutils literal notranslate"><span class="pre">showturtle()</span></code></a> | <a class="reference internal" href="#turtle.st" title="turtle.st"><code class="xref py py-func docutils literal notranslate"><span class="pre">st()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.hideturtle" title="turtle.hideturtle"><code class="xref py py-func docutils literal notranslate"><span class="pre">hideturtle()</span></code></a> | <a class="reference internal" href="#turtle.ht" title="turtle.ht"><code class="xref py py-func docutils literal notranslate"><span class="pre">ht()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.isvisible" title="turtle.isvisible"><code class="xref py py-func docutils literal notranslate"><span class="pre">isvisible()</span></code></a></div>
</div>
</dd>
<dt>Appearance</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.shape" title="turtle.shape"><code class="xref py py-func docutils literal notranslate"><span class="pre">shape()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.resizemode" title="turtle.resizemode"><code class="xref py py-func docutils literal notranslate"><span class="pre">resizemode()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.shapesize" title="turtle.shapesize"><code class="xref py py-func docutils literal notranslate"><span class="pre">shapesize()</span></code></a> | <a class="reference internal" href="#turtle.turtlesize" title="turtle.turtlesize"><code class="xref py py-func docutils literal notranslate"><span class="pre">turtlesize()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.settiltangle" title="turtle.settiltangle"><code class="xref py py-func docutils literal notranslate"><span class="pre">settiltangle()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.tiltangle" title="turtle.tiltangle"><code class="xref py py-func docutils literal notranslate"><span class="pre">tiltangle()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.tilt" title="turtle.tilt"><code class="xref py py-func docutils literal notranslate"><span class="pre">tilt()</span></code></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Using events</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.onclick" title="turtle.onclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">onclick()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.onrelease" title="turtle.onrelease"><code class="xref py py-func docutils literal notranslate"><span class="pre">onrelease()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.ondrag" title="turtle.ondrag"><code class="xref py py-func docutils literal notranslate"><span class="pre">ondrag()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.mainloop" title="turtle.mainloop"><code class="xref py py-func docutils literal notranslate"><span class="pre">mainloop()</span></code></a> | <a class="reference internal" href="#turtle.done" title="turtle.done"><code class="xref py py-func docutils literal notranslate"><span class="pre">done()</span></code></a></div>
</div>
</dd>
<dt>Special Turtle methods</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.begin_poly" title="turtle.begin_poly"><code class="xref py py-func docutils literal notranslate"><span class="pre">begin_poly()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.end_poly" title="turtle.end_poly"><code class="xref py py-func docutils literal notranslate"><span class="pre">end_poly()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.get_poly" title="turtle.get_poly"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_poly()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clone" title="turtle.clone"><code class="xref py py-func docutils literal notranslate"><span class="pre">clone()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getturtle" title="turtle.getturtle"><code class="xref py py-func docutils literal notranslate"><span class="pre">getturtle()</span></code></a> | <a class="reference internal" href="#turtle.getpen" title="turtle.getpen"><code class="xref py py-func docutils literal notranslate"><span class="pre">getpen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getscreen" title="turtle.getscreen"><code class="xref py py-func docutils literal notranslate"><span class="pre">getscreen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setundobuffer" title="turtle.setundobuffer"><code class="xref py py-func docutils literal notranslate"><span class="pre">setundobuffer()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.undobufferentries" title="turtle.undobufferentries"><code class="xref py py-func docutils literal notranslate"><span class="pre">undobufferentries()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.tracer" title="turtle.tracer"><code class="xref py py-func docutils literal notranslate"><span class="pre">tracer()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.window_width" title="turtle.window_width"><code class="xref py py-func docutils literal notranslate"><span class="pre">window_width()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.window_height" title="turtle.window_height"><code class="xref py py-func docutils literal notranslate"><span class="pre">window_height()</span></code></a></div>
</div>
</dd>
</dl>
</div>
<div class="section" id="methods-of-turtlescreen-screen">
<h3>24.5.2.2. Methods of TurtleScreen/Screen<a class="headerlink" href="#methods-of-turtlescreen-screen" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt>Window control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.bgcolor" title="turtle.bgcolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">bgcolor()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.bgpic" title="turtle.bgpic"><code class="xref py py-func docutils literal notranslate"><span class="pre">bgpic()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.clear" title="turtle.clear"><code class="xref py py-func docutils literal notranslate"><span class="pre">clear()</span></code></a> | <a class="reference internal" href="#turtle.clearscreen" title="turtle.clearscreen"><code class="xref py py-func docutils literal notranslate"><span class="pre">clearscreen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.reset" title="turtle.reset"><code class="xref py py-func docutils literal notranslate"><span class="pre">reset()</span></code></a> | <a class="reference internal" href="#turtle.resetscreen" title="turtle.resetscreen"><code class="xref py py-func docutils literal notranslate"><span class="pre">resetscreen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.screensize" title="turtle.screensize"><code class="xref py py-func docutils literal notranslate"><span class="pre">screensize()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setworldcoordinates" title="turtle.setworldcoordinates"><code class="xref py py-func docutils literal notranslate"><span class="pre">setworldcoordinates()</span></code></a></div>
</div>
</dd>
<dt>Animation control</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.delay" title="turtle.delay"><code class="xref py py-func docutils literal notranslate"><span class="pre">delay()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.tracer" title="turtle.tracer"><code class="xref py py-func docutils literal notranslate"><span class="pre">tracer()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.update" title="turtle.update"><code class="xref py py-func docutils literal notranslate"><span class="pre">update()</span></code></a></div>
</div>
</dd>
<dt>Using screen events</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.listen" title="turtle.listen"><code class="xref py py-func docutils literal notranslate"><span class="pre">listen()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.onkey" title="turtle.onkey"><code class="xref py py-func docutils literal notranslate"><span class="pre">onkey()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.onclick" title="turtle.onclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">onclick()</span></code></a> | <a class="reference internal" href="#turtle.onscreenclick" title="turtle.onscreenclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">onscreenclick()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.ontimer" title="turtle.ontimer"><code class="xref py py-func docutils literal notranslate"><span class="pre">ontimer()</span></code></a></div>
</div>
</dd>
<dt>Settings and special methods</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getcanvas" title="turtle.getcanvas"><code class="xref py py-func docutils literal notranslate"><span class="pre">getcanvas()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.getshapes" title="turtle.getshapes"><code class="xref py py-func docutils literal notranslate"><span class="pre">getshapes()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.register_shape" title="turtle.register_shape"><code class="xref py py-func docutils literal notranslate"><span class="pre">register_shape()</span></code></a> | <a class="reference internal" href="#turtle.addshape" title="turtle.addshape"><code class="xref py py-func docutils literal notranslate"><span class="pre">addshape()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.turtles" title="turtle.turtles"><code class="xref py py-func docutils literal notranslate"><span class="pre">turtles()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.window_height" title="turtle.window_height"><code class="xref py py-func docutils literal notranslate"><span class="pre">window_height()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.window_width" title="turtle.window_width"><code class="xref py py-func docutils literal notranslate"><span class="pre">window_width()</span></code></a></div>
</div>
</dd>
<dt>Methods specific to Screen</dt>
<dd><div class="first last line-block">
<div class="line"><a class="reference internal" href="#turtle.bye" title="turtle.bye"><code class="xref py py-func docutils literal notranslate"><span class="pre">bye()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.exitonclick" title="turtle.exitonclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">exitonclick()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.setup" title="turtle.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">setup()</span></code></a></div>
<div class="line"><a class="reference internal" href="#turtle.title" title="turtle.title"><code class="xref py py-func docutils literal notranslate"><span class="pre">title()</span></code></a></div>
</div>
</dd>
</dl>
</div>
</div>
<div class="section" id="methods-of-rawturtle-turtle-and-corresponding-functions">
<h2>24.5.3. Methods of RawTurtle/Turtle and corresponding functions<a class="headerlink" href="#methods-of-rawturtle-turtle-and-corresponding-functions" title="Permalink to this headline">¶</a></h2>
<p>Most of the examples in this section refer to a Turtle instance called
<code class="docutils literal notranslate"><span class="pre">turtle</span></code>.</p>
<div class="section" id="turtle-motion">
<h3>24.5.3.1. Turtle motion<a class="headerlink" href="#turtle-motion" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.forward">
<code class="descclassname">turtle.</code><code class="descname">forward</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.forward" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.fd">
<code class="descclassname">turtle.</code><code class="descname">fd</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.fd" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>distance</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Move the turtle forward by the specified <em>distance</em>, in the direction the
turtle is headed.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">25</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(25.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="o">-</span><span class="mi">75</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-50.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.back">
<code class="descclassname">turtle.</code><code class="descname">back</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.back" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.bk">
<code class="descclassname">turtle.</code><code class="descname">bk</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bk" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.backward">
<code class="descclassname">turtle.</code><code class="descname">backward</code><span class="sig-paren">(</span><em>distance</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.backward" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>distance</strong> – a number</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">backward</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-30.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.right">
<code class="descclassname">turtle.</code><code class="descname">right</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.right" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.rt">
<code class="descclassname">turtle.</code><code class="descname">rt</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.rt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<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 class="xref py py-func docutils literal notranslate"><span class="pre">degrees()</span></code></a> and <a class="reference internal" href="#turtle.radians" title="turtle.radians"><code class="xref py py-func docutils literal notranslate"><span class="pre">radians()</span></code></a> functions.)  Angle
orientation depends on the turtle mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">22.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">right</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">337.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.left">
<code class="descclassname">turtle.</code><code class="descname">left</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.left" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.lt">
<code class="descclassname">turtle.</code><code class="descname">lt</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.lt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<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 class="xref py py-func docutils literal notranslate"><span class="pre">degrees()</span></code></a> and <a class="reference internal" href="#turtle.radians" title="turtle.radians"><code class="xref py py-func docutils literal notranslate"><span class="pre">radians()</span></code></a> functions.)  Angle
orientation depends on the turtle mode, see <a class="reference internal" href="#turtle.mode" title="turtle.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">22.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">67.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.goto">
<code class="descclassname">turtle.</code><code class="descname">goto</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.goto" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.setpos">
<code class="descclassname">turtle.</code><code class="descname">setpos</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setpos" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.setposition">
<code class="descclassname">turtle.</code><code class="descname">setposition</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setposition" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – a number or a pair/vector of numbers</li>
<li><strong>y</strong> – a number or <code class="docutils literal notranslate"><span class="pre">None</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>If <em>y</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, <em>x</em> must be a pair of coordinates or a <a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code class="xref py py-class docutils literal notranslate"><span class="pre">Vec2D</span></code></a>
(e.g. as returned by <a class="reference internal" href="#turtle.pos" title="turtle.pos"><code class="xref py py-func docutils literal notranslate"><span class="pre">pos()</span></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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">tp</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tp</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">(</span><span class="mi">60</span><span class="p">,</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(60.00,30.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">((</span><span class="mi">20</span><span class="p">,</span><span class="mi">80</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(20.00,80.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">(</span><span class="n">tp</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setx">
<code class="descclassname">turtle.</code><code class="descname">setx</code><span class="sig-paren">(</span><em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setx" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the turtle’s first coordinate to <em>x</em>, leave second coordinate
unchanged.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,240.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setx</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(10.00,240.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.sety">
<code class="descclassname">turtle.</code><code class="descname">sety</code><span class="sig-paren">(</span><em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.sety" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>y</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the turtle’s second coordinate to <em>y</em>, leave first coordinate unchanged.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,40.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">sety</span><span class="p">(</span><span class="o">-</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,-10.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setheading">
<code class="descclassname">turtle.</code><code class="descname">setheading</code><span class="sig-paren">(</span><em>to_angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setheading" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.seth">
<code class="descclassname">turtle.</code><code class="descname">seth</code><span class="sig-paren">(</span><em>to_angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.seth" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>to_angle</strong> – a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the orientation of the turtle to <em>to_angle</em>.  Here are some common
directions in degrees:</p>
<table border="1" class="docutils">
<colgroup>
<col width="49%" />
<col width="51%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">standard mode</th>
<th class="head">logo mode</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>0 - east</td>
<td>0 - north</td>
</tr>
<tr class="row-odd"><td>90 - north</td>
<td>90 - east</td>
</tr>
<tr class="row-even"><td>180 - west</td>
<td>180 - south</td>
</tr>
<tr class="row-odd"><td>270 - south</td>
<td>270 - west</td>
</tr>
</tbody>
</table>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setheading</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.home">
<code class="descclassname">turtle.</code><code class="descname">home</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.home" title="Permalink to this definition">¶</a></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 class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,-10.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.circle">
<code class="descclassname">turtle.</code><code class="descname">circle</code><span class="sig-paren">(</span><em>radius</em>, <em>extent=None</em>, <em>steps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.circle" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>radius</strong> – a number</li>
<li><strong>extent</strong> – a number (or <code class="docutils literal notranslate"><span class="pre">None</span></code>)</li>
<li><strong>steps</strong> – an integer (or <code class="docutils literal notranslate"><span class="pre">None</span></code>)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mi">120</span><span class="p">,</span> <span class="mi">180</span><span class="p">)</span>  <span class="c1"># draw a semicircle</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,240.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">180.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.dot">
<code class="descclassname">turtle.</code><code class="descname">dot</code><span class="sig-paren">(</span><em>size=None</em>, <em>*color</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.dot" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> – an integer &gt;= 1 (if given)</li>
<li><strong>color</strong> – a colorstring or a numeric color tuple</li>
</ul>
</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">dot</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(100.00,-0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.stamp">
<code class="descclassname">turtle.</code><code class="descname">stamp</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.stamp" title="Permalink to this definition">¶</a></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 class="docutils literal notranslate"><span class="pre">clearstamp(stamp_id)</span></code>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">()</span>
<span class="go">11</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clearstamp">
<code class="descclassname">turtle.</code><code class="descname">clearstamp</code><span class="sig-paren">(</span><em>stampid</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clearstamp" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stampid</strong> – an integer, must be return value of previous
<a class="reference internal" href="#turtle.stamp" title="turtle.stamp"><code class="xref py py-func docutils literal notranslate"><span class="pre">stamp()</span></code></a> call</td>
</tr>
</tbody>
</table>
<p>Delete stamp with given <em>stampid</em>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(150.00,-0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">astamp</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(200.00,-0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamp</span><span class="p">(</span><span class="n">astamp</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(200.00,-0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clearstamps">
<code class="descclassname">turtle.</code><code class="descname">clearstamps</code><span class="sig-paren">(</span><em>n=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clearstamps" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>n</strong> – an integer (or <code class="docutils literal notranslate"><span class="pre">None</span></code>)</td>
</tr>
</tbody>
</table>
<p>Delete all or first/last <em>n</em> of turtle’s stamps.  If <em>n</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, delete
all stamps, if <em>n</em> &gt; 0 delete first <em>n</em> stamps, else if <em>n</em> &lt; 0 delete
last <em>n</em> stamps.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">();</span> <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="go">13</span>
<span class="go">14</span>
<span class="go">15</span>
<span class="go">16</span>
<span class="go">17</span>
<span class="go">18</span>
<span class="go">19</span>
<span class="go">20</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.undo">
<code class="descclassname">turtle.</code><code class="descname">undo</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.undo" title="Permalink to this definition">¶</a></dt>
<dd><p>Undo (repeatedly) the last turtle action(s).  Number of available
undo actions is determined by the size of the undobuffer.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">lt</span><span class="p">(</span><span class="mi">80</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">undo</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.speed">
<code class="descclassname">turtle.</code><code class="descname">speed</code><span class="sig-paren">(</span><em>speed=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.speed" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>speed</strong> – an integer in the range 0..10 or a speedstring (see below)</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">()</span>
<span class="go">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">(</span><span class="s1">&#39;normal&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">()</span>
<span class="go">6</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">(</span><span class="mi">9</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">()</span>
<span class="go">9</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="tell-turtle-s-state">
<h3>24.5.3.2. Tell Turtle’s state<a class="headerlink" href="#tell-turtle-s-state" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.position">
<code class="descclassname">turtle.</code><code class="descname">position</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.position" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pos">
<code class="descclassname">turtle.</code><code class="descname">pos</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pos" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle’s current location (x,y) (as a <a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code class="xref py py-class docutils literal notranslate"><span class="pre">Vec2D</span></code></a> vector).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(440.00,-0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.towards">
<code class="descclassname">turtle.</code><code class="descname">towards</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.towards" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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 class="docutils literal notranslate"><span class="pre">None</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">towards</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
<span class="go">225.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.xcor">
<code class="descclassname">turtle.</code><code class="descname">xcor</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.xcor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle’s x coordinate.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(64.28,76.60)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">turtle</span><span class="o">.</span><span class="n">xcor</span><span class="p">()</span>
<span class="go">64.2787609687</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ycor">
<code class="descclassname">turtle.</code><code class="descname">ycor</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ycor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle’s y coordinate.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(50.00,86.60)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">turtle</span><span class="o">.</span><span class="n">ycor</span><span class="p">()</span>
<span class="go">86.6025403784</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.heading">
<code class="descclassname">turtle.</code><code class="descname">heading</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.heading" title="Permalink to this definition">¶</a></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 class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a>).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">67</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">67.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.distance">
<code class="descclassname">turtle.</code><code class="descname">distance</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.distance" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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 class="docutils literal notranslate"><span class="pre">None</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return the distance from the turtle to (x,y), the given vector, or the given
other turtle, in turtle step units.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">(</span><span class="mi">30</span><span class="p">,</span><span class="mi">40</span><span class="p">)</span>
<span class="go">50.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">((</span><span class="mi">30</span><span class="p">,</span><span class="mi">40</span><span class="p">))</span>
<span class="go">50.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span> <span class="o">=</span> <span class="n">Turtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">77</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">(</span><span class="n">joe</span><span class="p">)</span>
<span class="go">77.0</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="settings-for-measurement">
<h3>24.5.3.3. Settings for measurement<a class="headerlink" href="#settings-for-measurement" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.degrees">
<code class="descclassname">turtle.</code><code class="descname">degrees</code><span class="sig-paren">(</span><em>fullcircle=360.0</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.degrees" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>fullcircle</strong> – a number</td>
</tr>
</tbody>
</table>
<p>Set angle measurement units, i.e. set number of “degrees” for a full circle.
Default value is 360 degrees.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>

<span class="go">Change angle measurement unit to grad (also known as gon,</span>
<span class="go">grade, or gradian and equals 1/100-th of the right angle.)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">degrees</span><span class="p">(</span><span class="mf">400.0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">100.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">degrees</span><span class="p">(</span><span class="mi">360</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.radians">
<code class="descclassname">turtle.</code><code class="descname">radians</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.radians" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the angle measurement units to radians.  Equivalent to
<code class="docutils literal notranslate"><span class="pre">degrees(2*math.pi)</span></code>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">radians</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">1.5707963267948966</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="pen-control">
<h3>24.5.3.4. Pen control<a class="headerlink" href="#pen-control" title="Permalink to this headline">¶</a></h3>
<div class="section" id="drawing-state">
<h4>24.5.3.4.1. Drawing state<a class="headerlink" href="#drawing-state" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.pendown">
<code class="descclassname">turtle.</code><code class="descname">pendown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pendown" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pd">
<code class="descclassname">turtle.</code><code class="descname">pd</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pd" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.down">
<code class="descclassname">turtle.</code><code class="descname">down</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.down" title="Permalink to this definition">¶</a></dt>
<dd><p>Pull the pen down – drawing when moving.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.penup">
<code class="descclassname">turtle.</code><code class="descname">penup</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.penup" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pu">
<code class="descclassname">turtle.</code><code class="descname">pu</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pu" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.up">
<code class="descclassname">turtle.</code><code class="descname">up</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.up" title="Permalink to this definition">¶</a></dt>
<dd><p>Pull the pen up – no drawing when moving.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.pensize">
<code class="descclassname">turtle.</code><code class="descname">pensize</code><span class="sig-paren">(</span><em>width=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pensize" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.width">
<code class="descclassname">turtle.</code><code class="descname">width</code><span class="sig-paren">(</span><em>width=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.width" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>width</strong> – a positive number</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">()</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>   <span class="c1"># from here on lines of width 10 are drawn</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.pen">
<code class="descclassname">turtle.</code><code class="descname">pen</code><span class="sig-paren">(</span><em>pen=None</em>, <em>**pendict</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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>
</td>
</tr>
</tbody>
</table>
<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 class="xref py py-func docutils literal notranslate"><span class="pre">pen()</span></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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">(</span><span class="n">fillcolor</span><span class="o">=</span><span class="s2">&quot;black&quot;</span><span class="p">,</span> <span class="n">pencolor</span><span class="o">=</span><span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="n">pensize</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>
<span class="go">[(&#39;fillcolor&#39;, &#39;black&#39;), (&#39;outline&#39;, 1), (&#39;pencolor&#39;, &#39;red&#39;),</span>
<span class="go"> (&#39;pendown&#39;, True), (&#39;pensize&#39;, 10), (&#39;resizemode&#39;, &#39;noresize&#39;),</span>
<span class="go"> (&#39;shown&#39;, True), (&#39;speed&#39;, 9), (&#39;stretchfactor&#39;, (1, 1)), (&#39;tilt&#39;, 0)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">penstate</span><span class="o">=</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;yellow&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>
<span class="go">[(&#39;fillcolor&#39;, &#39;&#39;), (&#39;outline&#39;, 1), (&#39;pencolor&#39;, &#39;yellow&#39;),</span>
<span class="go"> (&#39;pendown&#39;, False), (&#39;pensize&#39;, 10), (&#39;resizemode&#39;, &#39;noresize&#39;),</span>
<span class="go"> (&#39;shown&#39;, True), (&#39;speed&#39;, 9), (&#39;stretchfactor&#39;, (1, 1)), (&#39;tilt&#39;, 0)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">(</span><span class="n">penstate</span><span class="p">,</span> <span class="n">fillcolor</span><span class="o">=</span><span class="s2">&quot;green&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>
<span class="go">[(&#39;fillcolor&#39;, &#39;green&#39;), (&#39;outline&#39;, 1), (&#39;pencolor&#39;, &#39;red&#39;),</span>
<span class="go"> (&#39;pendown&#39;, True), (&#39;pensize&#39;, 10), (&#39;resizemode&#39;, &#39;noresize&#39;),</span>
<span class="go"> (&#39;shown&#39;, True), (&#39;speed&#39;, 9), (&#39;stretchfactor&#39;, (1, 1)), (&#39;tilt&#39;, 0)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.isdown">
<code class="descclassname">turtle.</code><code class="descname">isdown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.isdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if pen is down, <code class="docutils literal notranslate"><span class="pre">False</span></code> if it’s up.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isdown</span><span class="p">()</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pendown</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isdown</span><span class="p">()</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="color-control">
<h4>24.5.3.4.2. Color control<a class="headerlink" href="#color-control" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.pencolor">
<code class="descclassname">turtle.</code><code class="descname">pencolor</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.pencolor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set the pencolor.</p>
<p>Four input formats are allowed:</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">pencolor()</span></code></dt>
<dd>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.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">pencolor(colorstring)</span></code></dt>
<dd>Set pencolor to <em>colorstring</em>, which is a Tk color specification string,
such as <code class="docutils literal notranslate"><span class="pre">&quot;red&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;yellow&quot;</span></code>, or <code class="docutils literal notranslate"><span class="pre">&quot;#33cc8c&quot;</span></code>.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">pencolor((r,</span> <span class="pre">g,</span> <span class="pre">b))</span></code></dt>
<dd>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 class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a>).</dd>
<dt><code class="docutils literal notranslate"><span class="pre">pencolor(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></code></dt>
<dd><blockquote class="first">
<div>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.</div></blockquote>
<p class="last">If turtleshape is a polygon, the outline of that polygon is drawn with the
newly set pencolor.</p>
</dd>
</dl>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">colormode</span><span class="p">()</span>
<span class="go">1.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">&#39;red&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="s2">&quot;brown&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">&#39;brown&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tup</span> <span class="o">=</span> <span class="p">(</span><span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.8</span><span class="p">,</span> <span class="mf">0.55</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="n">tup</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">(0.2, 0.8, 0.5490196078431373)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">colormode</span><span class="p">(</span><span class="mi">255</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">(51, 204, 140)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="s1">&#39;#32c18f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">(50, 193, 143)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.fillcolor">
<code class="descclassname">turtle.</code><code class="descname">fillcolor</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.fillcolor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set the fillcolor.</p>
<p>Four input formats are allowed:</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor()</span></code></dt>
<dd>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.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor(colorstring)</span></code></dt>
<dd>Set fillcolor to <em>colorstring</em>, which is a Tk color specification string,
such as <code class="docutils literal notranslate"><span class="pre">&quot;red&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;yellow&quot;</span></code>, or <code class="docutils literal notranslate"><span class="pre">&quot;#33cc8c&quot;</span></code>.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor((r,</span> <span class="pre">g,</span> <span class="pre">b))</span></code></dt>
<dd>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 class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a>).</dd>
<dt><code class="docutils literal notranslate"><span class="pre">fillcolor(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></code></dt>
<dd><blockquote class="first">
<div>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.</div></blockquote>
<p class="last">If turtleshape is a polygon, the interior of that polygon is drawn
with the newly set fillcolor.</p>
</dd>
</dl>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s2">&quot;violet&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">()</span>
<span class="go">&#39;violet&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">col</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">col</span>
<span class="go">(50, 193, 143)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="n">col</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">()</span>
<span class="go">(50, 193, 143)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s1">&#39;#ffffff&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">()</span>
<span class="go">(255, 255, 255)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.color">
<code class="descclassname">turtle.</code><code class="descname">color</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.color" title="Permalink to this definition">¶</a></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="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">color()</span></code></dt>
<dd>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 class="xref py py-func docutils literal notranslate"><span class="pre">pencolor()</span></code></a> and
<a class="reference internal" href="#turtle.fillcolor" title="turtle.fillcolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">fillcolor()</span></code></a>.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">color(colorstring)</span></code>, <code class="docutils literal notranslate"><span class="pre">color((r,g,b))</span></code>, <code class="docutils literal notranslate"><span class="pre">color(r,g,b)</span></code></dt>
<dd>Inputs as in <a class="reference internal" href="#turtle.pencolor" title="turtle.pencolor"><code class="xref py py-func docutils literal notranslate"><span class="pre">pencolor()</span></code></a>, set both, fillcolor and pencolor, to the
given value.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">color(colorstring1,</span> <span class="pre">colorstring2)</span></code>, <code class="docutils literal notranslate"><span class="pre">color((r1,g1,b1),</span> <span class="pre">(r2,g2,b2))</span></code></dt>
<dd><blockquote class="first">
<div>Equivalent to <code class="docutils literal notranslate"><span class="pre">pencolor(colorstring1)</span></code> and <code class="docutils literal notranslate"><span class="pre">fillcolor(colorstring2)</span></code>
and analogously if the other input format is used.</div></blockquote>
<p class="last">If turtleshape is a polygon, outline and interior of that polygon is drawn
with the newly set colors.</p>
</dd>
</dl>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="s2">&quot;green&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">()</span>
<span class="go">(&#39;red&#39;, &#39;green&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;#285078&quot;</span><span class="p">,</span> <span class="s2">&quot;#a0c8f0&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">color</span><span class="p">()</span>
<span class="go">((40, 80, 120), (160, 200, 240))</span>
</pre></div>
</div>
</dd></dl>

<p>See also: Screen method <a class="reference internal" href="#turtle.colormode" title="turtle.colormode"><code class="xref py py-func docutils literal notranslate"><span class="pre">colormode()</span></code></a>.</p>
</div>
<div class="section" id="filling">
<h4>24.5.3.4.3. Filling<a class="headerlink" href="#filling" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.fill">
<code class="descclassname">turtle.</code><code class="descname">fill</code><span class="sig-paren">(</span><em>flag</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.fill" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>flag</strong> – True/False (or 1/0 respectively)</td>
</tr>
</tbody>
</table>
<p>Call <code class="docutils literal notranslate"><span class="pre">fill(True)</span></code> before drawing the shape you want to fill, and
<code class="docutils literal notranslate"><span class="pre">fill(False)</span></code> when done.  When used without argument: return fillstate
(<code class="docutils literal notranslate"><span class="pre">True</span></code> if filling, <code class="docutils literal notranslate"><span class="pre">False</span></code> else).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fill</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
<span class="gp">... </span>   <span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">... </span>   <span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">120</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fill</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.begin_fill">
<code class="descclassname">turtle.</code><code class="descname">begin_fill</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.begin_fill" title="Permalink to this definition">¶</a></dt>
<dd><p>Call just before drawing a shape to be filled.  Equivalent to <code class="docutils literal notranslate"><span class="pre">fill(True)</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.end_fill">
<code class="descclassname">turtle.</code><code class="descname">end_fill</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.end_fill" title="Permalink to this definition">¶</a></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 class="xref py py-func docutils literal notranslate"><span class="pre">begin_fill()</span></code></a>.  Equivalent
to <code class="docutils literal notranslate"><span class="pre">fill(False)</span></code>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;black&quot;</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">begin_fill</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mi">80</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">end_fill</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="more-drawing-control">
<h4>24.5.3.4.4. More drawing control<a class="headerlink" href="#more-drawing-control" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.reset">
<code class="descclassname">turtle.</code><code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the turtle’s drawings from the screen, re-center the turtle and set
variables to the default values.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="o">-</span><span class="mi">22</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,-22.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">100.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clear">
<code class="descclassname">turtle.</code><code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clear" title="Permalink to this definition">¶</a></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="function">
<dt id="turtle.write">
<code class="descclassname">turtle.</code><code class="descname">write</code><span class="sig-paren">(</span><em>arg</em>, <em>move=False</em>, <em>align=&quot;left&quot;</em>, <em>font=(&quot;Arial&quot;</em>, <em>8</em>, <em>&quot;normal&quot;)</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.write" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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>
</td>
</tr>
</tbody>
</table>
<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 class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;Home = &quot;</span><span class="p">,</span> <span class="kc">True</span><span class="p">,</span> <span class="n">align</span><span class="o">=</span><span class="s2">&quot;center&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">write</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="turtle-state">
<h3>24.5.3.5. Turtle state<a class="headerlink" href="#turtle-state" title="Permalink to this headline">¶</a></h3>
<div class="section" id="visibility">
<h4>24.5.3.5.1. Visibility<a class="headerlink" href="#visibility" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.hideturtle">
<code class="descclassname">turtle.</code><code class="descname">hideturtle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.hideturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.ht">
<code class="descclassname">turtle.</code><code class="descname">ht</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ht" title="Permalink to this definition">¶</a></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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">hideturtle</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.showturtle">
<code class="descclassname">turtle.</code><code class="descname">showturtle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.showturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.st">
<code class="descclassname">turtle.</code><code class="descname">st</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.st" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the turtle visible.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">showturtle</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.isvisible">
<code class="descclassname">turtle.</code><code class="descname">isvisible</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.isvisible" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the Turtle is shown, <code class="docutils literal notranslate"><span class="pre">False</span></code> if it’s hidden.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">hideturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isvisible</span><span class="p">()</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">showturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isvisible</span><span class="p">()</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="appearance">
<h4>24.5.3.5.2. Appearance<a class="headerlink" href="#appearance" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.shape">
<code class="descclassname">turtle.</code><code class="descname">shape</code><span class="sig-paren">(</span><em>name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.shape" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> – a string which is a valid shapename</td>
</tr>
</tbody>
</table>
<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 class="xref py py-func docutils literal notranslate"><span class="pre">register_shape()</span></code></a>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">()</span>
<span class="go">&#39;classic&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;turtle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">()</span>
<span class="go">&#39;turtle&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.resizemode">
<code class="descclassname">turtle.</code><code class="descname">resizemode</code><span class="sig-paren">(</span><em>rmode=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.resizemode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>rmode</strong> – one of the strings “auto”, “user”, “noresize”</td>
</tr>
</tbody>
</table>
<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 class="xref py py-func docutils literal notranslate"><span class="pre">shapesize()</span></code></a>.</li>
<li>“noresize”: no adaption of the turtle’s appearance takes place.</li>
</ul>
<p>resizemode(“user”) is called by <a class="reference internal" href="#turtle.shapesize" title="turtle.shapesize"><code class="xref py py-func docutils literal notranslate"><span class="pre">shapesize()</span></code></a> when used with arguments.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">()</span>
<span class="go">&#39;noresize&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">(</span><span class="s2">&quot;auto&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">()</span>
<span class="go">&#39;auto&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.shapesize">
<code class="descclassname">turtle.</code><code class="descname">shapesize</code><span class="sig-paren">(</span><em>stretch_wid=None</em>, <em>stretch_len=None</em>, <em>outline=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.shapesize" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.turtlesize">
<code class="descclassname">turtle.</code><code class="descname">turtlesize</code><span class="sig-paren">(</span><em>stretch_wid=None</em>, <em>stretch_len=None</em>, <em>outline=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.turtlesize" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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>
</td>
</tr>
</tbody>
</table>
<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 shapes’s outline.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">()</span>
<span class="go">(1, 1, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">(</span><span class="s2">&quot;user&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">()</span>
<span class="go">(5, 5, 12)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="n">outline</span><span class="o">=</span><span class="mi">8</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">()</span>
<span class="go">(5, 5, 8)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tilt">
<code class="descclassname">turtle.</code><code class="descname">tilt</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.tilt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.settiltangle">
<code class="descclassname">turtle.</code><code class="descname">settiltangle</code><span class="sig-paren">(</span><em>angle</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.settiltangle" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>angle</strong> – a number</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">settiltangle</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">settiltangle</span><span class="p">(</span><span class="o">-</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tiltangle">
<code class="descclassname">turtle.</code><code class="descname">tiltangle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.tiltangle" title="Permalink to this definition">¶</a></dt>
<dd><p>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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tiltangle</span><span class="p">()</span>
<span class="go">45.0</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="using-events">
<h3>24.5.3.6. Using events<a class="headerlink" href="#using-events" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.onclick">
<code class="descclassname">turtle.</code><code class="descname">onclick</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onclick" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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 class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-click events on this turtle.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>,
existing bindings are removed.  Example for the anonymous turtle, i.e. the
procedural way:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">turn</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">onclick</span><span class="p">(</span><span class="n">turn</span><span class="p">)</span>  <span class="c1"># Now clicking into the turtle will turn it.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">onclick</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>  <span class="c1"># event-binding will be removed</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.onrelease">
<code class="descclassname">turtle.</code><code class="descname">onrelease</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onrelease" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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 class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-button-release events on this turtle.  If <em>fun</em> is
<code class="docutils literal notranslate"><span class="pre">None</span></code>, existing bindings are removed.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">MyTurtle</span><span class="p">(</span><span class="n">Turtle</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">glow</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s2">&quot;red&quot;</span><span class="p">)</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">unglow</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span> <span class="o">=</span> <span class="n">MyTurtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">glow</span><span class="p">)</span>     <span class="c1"># clicking on turtle turns fillcolor red,</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">onrelease</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">unglow</span><span class="p">)</span> <span class="c1"># releasing turns it to transparent.</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ondrag">
<code class="descclassname">turtle.</code><code class="descname">ondrag</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ondrag" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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 class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-move events on this turtle.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">ondrag</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">)</span>
</pre></div>
</div>
<p>Subsequently, clicking and dragging the Turtle will move it across
the screen thereby producing handdrawings (if pen is down).</p>
</dd></dl>

<dl class="function">
<dt id="turtle.mainloop">
<code class="descclassname">turtle.</code><code class="descname">mainloop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.mainloop" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.done">
<code class="descclassname">turtle.</code><code class="descname">done</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.done" title="Permalink to this definition">¶</a></dt>
<dd><p>Starts event loop - calling Tkinter’s mainloop function. Must be the last
statement in a turtle graphics program.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="special-turtle-methods">
<h3>24.5.3.7. Special Turtle methods<a class="headerlink" href="#special-turtle-methods" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.begin_poly">
<code class="descclassname">turtle.</code><code class="descname">begin_poly</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.begin_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Start recording the vertices of a polygon.  Current turtle position is first
vertex of polygon.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.end_poly">
<code class="descclassname">turtle.</code><code class="descname">end_poly</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.end_poly" title="Permalink to this definition">¶</a></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="function">
<dt id="turtle.get_poly">
<code class="descclassname">turtle.</code><code class="descname">get_poly</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.get_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the last recorded polygon.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">home</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">begin_poly</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">end_poly</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">get_poly</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;myFavouriteShape&quot;</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clone">
<code class="descclassname">turtle.</code><code class="descname">clone</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clone" title="Permalink to this definition">¶</a></dt>
<dd><p>Create and return a clone of the turtle with same position, heading and
turtle properties.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">mick</span> <span class="o">=</span> <span class="n">Turtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span> <span class="o">=</span> <span class="n">mick</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getturtle">
<code class="descclassname">turtle.</code><code class="descname">getturtle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.getpen">
<code class="descclassname">turtle.</code><code class="descname">getpen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getpen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Turtle object itself.  Only reasonable use: as a function to
return the “anonymous turtle”:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span> <span class="o">=</span> <span class="n">getturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span>
<span class="go">&lt;turtle.Turtle object at 0x...&gt;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getscreen">
<code class="descclassname">turtle.</code><code class="descname">getscreen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a> object the turtle is drawing on.
TurtleScreen methods can then be called for that object.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">getscreen</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span>
<span class="go">&lt;turtle._Screen object at 0x...&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s2">&quot;pink&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setundobuffer">
<code class="descclassname">turtle.</code><code class="descname">setundobuffer</code><span class="sig-paren">(</span><em>size</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setundobuffer" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>size</strong> – an integer or <code class="docutils literal notranslate"><span class="pre">None</span></code></td>
</tr>
</tbody>
</table>
<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 class="xref py py-func docutils literal notranslate"><span class="pre">undo()</span></code></a> method/function.  If <em>size</em> is
<code class="docutils literal notranslate"><span class="pre">None</span></code>, the undobuffer is disabled.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setundobuffer</span><span class="p">(</span><span class="mi">42</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.undobufferentries">
<code class="descclassname">turtle.</code><code class="descname">undobufferentries</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.undobufferentries" title="Permalink to this definition">¶</a></dt>
<dd><p>Return number of entries in the undobuffer.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">while</span> <span class="n">undobufferentries</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">undo</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tracer">
<code class="descclassname">turtle.</code><code class="descname">tracer</code><span class="sig-paren">(</span><em>flag=None</em>, <em>delay=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.tracer" title="Permalink to this definition">¶</a></dt>
<dd><p>A replica of the corresponding TurtleScreen method.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 2.6.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.window_width">
<code class="descclassname">turtle.</code><code class="descname">window_width</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.window_width" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.window_height">
<code class="descclassname">turtle.</code><code class="descname">window_height</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.window_height" title="Permalink to this definition">¶</a></dt>
<dd><p>Both are replicas of the corresponding TurtleScreen methods.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 2.6.</span></p>
</div>
</dd></dl>

</div>
<div class="section" id="excursus-about-the-use-of-compound-shapes">
<span id="compoundshapes"></span><h3>24.5.3.8. Excursus about the use of compound shapes<a class="headerlink" href="#excursus-about-the-use-of-compound-shapes" title="Permalink to this headline">¶</a></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 class="xref py py-class docutils literal notranslate"><span class="pre">Shape</span></code></a> explicitly as described
below:</p>
<ol class="arabic">
<li><p class="first">Create an empty Shape object of type “compound”.</p>
</li>
<li><p class="first">Add as many components to this object as desired, using the
<code class="xref py py-meth docutils literal notranslate"><span class="pre">addcomponent()</span></code> method.</p>
<p>For example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">Shape</span><span class="p">(</span><span class="s2">&quot;compound&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly1</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),(</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">),(</span><span class="mi">0</span><span class="p">,</span><span class="mi">10</span><span class="p">),(</span><span class="o">-</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly1</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly2</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),(</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">),(</span><span class="o">-</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly2</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Now add the Shape to the Screen’s shapelist and use it:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;myshape&quot;</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">shape</span><span class="p">(</span><span class="s2">&quot;myshape&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ol>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code class="xref py py-class docutils literal notranslate"><span class="pre">Shape</span></code></a> class is used internally by the <a class="reference internal" href="#turtle.register_shape" title="turtle.register_shape"><code class="xref py py-func docutils literal notranslate"><span class="pre">register_shape()</span></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>
</div>
</div>
<div class="section" id="methods-of-turtlescreen-screen-and-corresponding-functions">
<h2>24.5.4. Methods of TurtleScreen/Screen and corresponding functions<a class="headerlink" href="#methods-of-turtlescreen-screen-and-corresponding-functions" title="Permalink to this headline">¶</a></h2>
<p>Most of the examples in this section refer to a TurtleScreen instance called
<code class="docutils literal notranslate"><span class="pre">screen</span></code>.</p>
<div class="section" id="window-control">
<h3>24.5.4.1. Window control<a class="headerlink" href="#window-control" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.bgcolor">
<code class="descclassname">turtle.</code><code class="descname">bgcolor</code><span class="sig-paren">(</span><em>*args</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bgcolor" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>args</strong> – a color string or three numbers in the range 0..colormode or a
3-tuple of such numbers</td>
</tr>
</tbody>
</table>
<p>Set or return background color of the TurtleScreen.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s2">&quot;orange&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">()</span>
<span class="go">&#39;orange&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s2">&quot;#800080&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">()</span>
<span class="go">(128, 0, 128)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.bgpic">
<code class="descclassname">turtle.</code><code class="descname">bgpic</code><span class="sig-paren">(</span><em>picname=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bgpic" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>picname</strong> – a string, name of a gif-file or <code class="docutils literal notranslate"><span class="pre">&quot;nopic&quot;</span></code>, or <code class="docutils literal notranslate"><span class="pre">None</span></code></td>
</tr>
</tbody>
</table>
<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 class="docutils literal notranslate"><span class="pre">&quot;nopic&quot;</span></code>, delete background image, if present.  If <em>picname</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>,
return the filename of the current backgroundimage.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">()</span>
<span class="go">&#39;nopic&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">(</span><span class="s2">&quot;landscape.gif&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">()</span>
<span class="go">&quot;landscape.gif&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dt id="turtle.clearscreen">
<code class="descclassname">turtle.</code><code class="descname">clearscreen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.clearscreen" title="Permalink to this definition">¶</a></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>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <code class="docutils literal notranslate"><span class="pre">clearscreen</span></code>.  The global function <code class="docutils literal notranslate"><span class="pre">clear</span></code> is another one
derived from the Turtle method <code class="docutils literal notranslate"><span class="pre">clear</span></code>.</p>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dt id="turtle.resetscreen">
<code class="descclassname">turtle.</code><code class="descname">resetscreen</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.resetscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset all Turtles on the Screen to their initial state.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <code class="docutils literal notranslate"><span class="pre">resetscreen</span></code>.  The global function <code class="docutils literal notranslate"><span class="pre">reset</span></code> is another one
derived from the Turtle method <code class="docutils literal notranslate"><span class="pre">reset</span></code>.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.screensize">
<code class="descclassname">turtle.</code><code class="descname">screensize</code><span class="sig-paren">(</span><em>canvwidth=None</em>, <em>canvheight=None</em>, <em>bg=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.screensize" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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>
</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">screensize</span><span class="p">()</span>
<span class="go">(400, 300)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">screensize</span><span class="p">(</span><span class="mi">2000</span><span class="p">,</span><span class="mi">1500</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">screensize</span><span class="p">()</span>
<span class="go">(2000, 1500)</span>
</pre></div>
</div>
<p>e.g. to search for an erroneously escaped turtle ;-)</p>
</dd></dl>

<dl class="function">
<dt id="turtle.setworldcoordinates">
<code class="descclassname">turtle.</code><code class="descname">setworldcoordinates</code><span class="sig-paren">(</span><em>llx</em>, <em>lly</em>, <em>urx</em>, <em>ury</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setworldcoordinates" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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>
</td>
</tr>
</tbody>
</table>
<p>Set up user-defined coordinate system and switch to mode “world” if
necessary.  This performs a <code class="docutils literal notranslate"><span class="pre">screen.reset()</span></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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setworldcoordinates</span><span class="p">(</span><span class="o">-</span><span class="mi">50</span><span class="p">,</span><span class="o">-</span><span class="mf">7.5</span><span class="p">,</span><span class="mi">50</span><span class="p">,</span><span class="mf">7.5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">72</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mi">45</span><span class="p">);</span> <span class="n">fd</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>   <span class="c1"># a regular octagon</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="animation-control">
<h3>24.5.4.2. Animation control<a class="headerlink" href="#animation-control" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.delay">
<code class="descclassname">turtle.</code><code class="descname">delay</code><span class="sig-paren">(</span><em>delay=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.delay" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>delay</strong> – positive integer</td>
</tr>
</tbody>
</table>
<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>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">()</span>
<span class="go">10</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">()</span>
<span class="go">5</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">tracer</code><span class="sig-paren">(</span><em>n=None</em>, <em>delay=None</em><span class="sig-paren">)</span></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>n</strong> – nonnegative integer</li>
<li><strong>delay</strong> – nonnegative integer</li>
</ul>
</td>
</tr>
</tbody>
</table>
<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.)  Second argument sets
delay value (see <a class="reference internal" href="#turtle.delay" title="turtle.delay"><code class="xref py py-func docutils literal notranslate"><span class="pre">delay()</span></code></a>).</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">tracer</span><span class="p">(</span><span class="mi">8</span><span class="p">,</span> <span class="mi">25</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span> <span class="o">=</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">200</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">fd</span><span class="p">(</span><span class="n">dist</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">rt</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">dist</span> <span class="o">+=</span> <span class="mi">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.update">
<code class="descclassname">turtle.</code><code class="descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.update" title="Permalink to this definition">¶</a></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 class="xref py py-func docutils literal notranslate"><span class="pre">speed()</span></code></a>.</p>
</div>
<div class="section" id="using-screen-events">
<h3>24.5.4.3. Using screen events<a class="headerlink" href="#using-screen-events" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.listen">
<code class="descclassname">turtle.</code><code class="descname">listen</code><span class="sig-paren">(</span><em>xdummy=None</em>, <em>ydummy=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.listen" title="Permalink to this definition">¶</a></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 class="xref py py-func docutils literal notranslate"><span class="pre">listen()</span></code></a> to the onclick method.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.onkey">
<code class="descclassname">turtle.</code><code class="descname">onkey</code><span class="sig-paren">(</span><em>fun</em>, <em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onkey" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with no arguments or <code class="docutils literal notranslate"><span class="pre">None</span></code></li>
<li><strong>key</strong> – a string: key (e.g. “a”) or key-symbol (e.g. “space”)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to key-release event of key.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></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 class="xref py py-func docutils literal notranslate"><span class="pre">listen()</span></code></a>.)</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">lt</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onkey</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s2">&quot;Up&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">listen</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">onclick</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span></dt>
<dt id="turtle.onscreenclick">
<code class="descclassname">turtle.</code><code class="descname">onscreenclick</code><span class="sig-paren">(</span><em>fun</em>, <em>btn=1</em>, <em>add=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.onscreenclick" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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 class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> – if <code class="docutils literal notranslate"><span class="pre">True</span></code>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-click events on this screen.  If <em>fun</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>,
existing bindings are removed.</p>
<p>Example for a TurtleScreen instance named <code class="docutils literal notranslate"><span class="pre">screen</span></code> and a Turtle instance
named turtle:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">)</span> <span class="c1"># Subsequently clicking into the TurtleScreen will</span>
<span class="gp">&gt;&gt;&gt; </span>                            <span class="c1"># make the turtle move to the clicked point.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>        <span class="c1"># remove event binding again</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <code class="docutils literal notranslate"><span class="pre">onscreenclick</span></code>.  The global function <code class="docutils literal notranslate"><span class="pre">onclick</span></code> is another one
derived from the Turtle method <code class="docutils literal notranslate"><span class="pre">onclick</span></code>.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ontimer">
<code class="descclassname">turtle.</code><code class="descname">ontimer</code><span class="sig-paren">(</span><em>fun</em>, <em>t=0</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ontimer" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> – a function with no arguments</li>
<li><strong>t</strong> – a number &gt;= 0</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Install a timer that calls <em>fun</em> after <em>t</em> milliseconds.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">running</span> <span class="o">=</span> <span class="bp">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span>    <span class="k">if</span> <span class="n">running</span><span class="p">:</span>
<span class="gp">... </span>        <span class="n">fd</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="gp">... </span>        <span class="n">lt</span><span class="p">(</span><span class="mi">60</span><span class="p">)</span>
<span class="gp">... </span>        <span class="n">screen</span><span class="o">.</span><span class="n">ontimer</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">250</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">()</span>   <span class="c1">### makes the turtle march around</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">running</span> <span class="o">=</span> <span class="bp">False</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="settings-and-special-methods">
<h3>24.5.4.4. Settings and special methods<a class="headerlink" href="#settings-and-special-methods" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.mode">
<code class="descclassname">turtle.</code><code class="descname">mode</code><span class="sig-paren">(</span><em>mode=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.mode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mode</strong> – one of the strings “standard”, “logo” or “world”</td>
</tr>
</tbody>
</table>
<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: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></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 class="docutils literal notranslate"><span class="pre">x/y</span></code> unit-ratio doesn’t equal 1.</p>
<table border="1" class="docutils">
<colgroup>
<col width="21%" />
<col width="45%" />
<col width="34%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Mode</th>
<th class="head">Initial turtle heading</th>
<th class="head">positive angles</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>“standard”</td>
<td>to the right (east)</td>
<td>counterclockwise</td>
</tr>
<tr class="row-odd"><td>“logo”</td>
<td>upward    (north)</td>
<td>clockwise</td>
</tr>
</tbody>
</table>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">mode</span><span class="p">(</span><span class="s2">&quot;logo&quot;</span><span class="p">)</span>   <span class="c1"># resets turtle heading to north</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mode</span><span class="p">()</span>
<span class="go">&#39;logo&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.colormode">
<code class="descclassname">turtle.</code><code class="descname">colormode</code><span class="sig-paren">(</span><em>cmode=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.colormode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>cmode</strong> – one of the values 1.0 or 255</td>
</tr>
</tbody>
</table>
<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..<em>cmode</em>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="mi">240</span><span class="p">,</span> <span class="mi">160</span><span class="p">,</span> <span class="mi">80</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
     <span class="o">...</span>
<span class="gr">TurtleGraphicsError</span>: <span class="n">bad color sequence: (240, 160, 80)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">()</span>
<span class="go">1.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">(</span><span class="mi">255</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">()</span>
<span class="go">255</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="mi">240</span><span class="p">,</span><span class="mi">160</span><span class="p">,</span><span class="mi">80</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getcanvas">
<code class="descclassname">turtle.</code><code class="descname">getcanvas</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getcanvas" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Canvas of this TurtleScreen.  Useful for insiders who know what to
do with a Tkinter Canvas.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cv</span> <span class="o">=</span> <span class="n">screen</span><span class="o">.</span><span class="n">getcanvas</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cv</span>
<span class="go">&lt;turtle.ScrolledCanvas instance at 0x...&gt;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getshapes">
<code class="descclassname">turtle.</code><code class="descname">getshapes</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.getshapes" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of names of all currently available turtle shapes.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">getshapes</span><span class="p">()</span>
<span class="go">[&#39;arrow&#39;, &#39;blank&#39;, &#39;circle&#39;, ..., &#39;turtle&#39;]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.register_shape">
<code class="descclassname">turtle.</code><code class="descname">register_shape</code><span class="sig-paren">(</span><em>name</em>, <em>shape=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.register_shape" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.addshape">
<code class="descclassname">turtle.</code><code class="descname">addshape</code><span class="sig-paren">(</span><em>name</em>, <em>shape=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.addshape" title="Permalink to this definition">¶</a></dt>
<dd><p>There are three different ways to call this function:</p>
<ol class="arabic">
<li><p class="first"><em>name</em> is the name of a gif-file and <em>shape</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>: Install the
corresponding image shape.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;turtle.gif&quot;</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">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 class="first"><em>name</em> is an arbitrary string and <em>shape</em> is a tuple of pairs of
coordinates: Install the corresponding polygon shape.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">register_shape</span><span class="p">(</span><span class="s2">&quot;triangle&quot;</span><span class="p">,</span> <span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="o">-</span><span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span><span class="o">-</span><span class="mi">3</span><span class="p">)))</span>
</pre></div>
</div>
</li>
<li><p class="first"><em>name</em> is an arbitrary string and shape is a (compound) <a class="reference internal" href="#turtle.Shape" title="turtle.Shape"><code class="xref py py-class docutils literal notranslate"><span class="pre">Shape</span></code></a>
object: Install the corresponding compound shape.</p>
</li>
</ol>
<p>Add a turtle shape to TurtleScreen’s shapelist.  Only thusly registered
shapes can be used by issuing the command <code class="docutils literal notranslate"><span class="pre">shape(shapename)</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.turtles">
<code class="descclassname">turtle.</code><code class="descname">turtles</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.turtles" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of turtles on the screen.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">turtle</span> <span class="ow">in</span> <span class="n">screen</span><span class="o">.</span><span class="n">turtles</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s2">&quot;red&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">window_height</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dd><p>Return the height of the turtle window.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">window_height</span><span class="p">()</span>
<span class="go">480</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descclassname">turtle.</code><code class="descname">window_width</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dd><p>Return the width of the turtle window.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">window_width</span><span class="p">()</span>
<span class="go">640</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="methods-specific-to-screen-not-inherited-from-turtlescreen">
<span id="screenspecific"></span><h3>24.5.4.5. Methods specific to Screen, not inherited from TurtleScreen<a class="headerlink" href="#methods-specific-to-screen-not-inherited-from-turtlescreen" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.bye">
<code class="descclassname">turtle.</code><code class="descname">bye</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.bye" title="Permalink to this definition">¶</a></dt>
<dd><p>Shut the turtlegraphics window.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.exitonclick">
<code class="descclassname">turtle.</code><code class="descname">exitonclick</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#turtle.exitonclick" title="Permalink to this definition">¶</a></dt>
<dd><p>Bind bye() method to mouse clicks on the Screen.</p>
<p>If the value “using_IDLE” in the configuration dictionary is <code class="docutils literal notranslate"><span class="pre">False</span></code>
(default value), also enter mainloop.  Remark: If IDLE with the <code class="docutils literal notranslate"><span class="pre">-n</span></code> switch
(no subprocess) is used, this value should be set to <code class="docutils literal notranslate"><span class="pre">True</span></code> in
<code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code>.  In this case IDLE’s own mainloop is active also for the
client script.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.setup">
<code class="descclassname">turtle.</code><code class="descname">setup</code><span class="sig-paren">(</span><em>width=_CFG[&quot;width&quot;], height=_CFG[&quot;height&quot;], startx=_CFG[&quot;leftright&quot;], starty=_CFG[&quot;topbottom&quot;]</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.setup" title="Permalink to this definition">¶</a></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 class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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 class="docutils literal notranslate"><span class="pre">None</span></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 class="docutils literal notranslate"><span class="pre">None</span></code>,
center window vertically</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setup</span> <span class="p">(</span><span class="n">width</span><span class="o">=</span><span class="mi">200</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">200</span><span class="p">,</span> <span class="n">startx</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">starty</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span>             <span class="c1"># sets window to 200x200 pixels, in upper left of screen</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setup</span><span class="p">(</span><span class="n">width</span><span class="o">=.</span><span class="mi">75</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">startx</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">starty</span><span class="o">=</span><span class="bp">None</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span>             <span class="c1"># sets window to 75% of screen by 50% of screen and centers</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.title">
<code class="descclassname">turtle.</code><code class="descname">title</code><span class="sig-paren">(</span><em>titlestring</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.title" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>titlestring</strong> – a string that is shown in the titlebar of the turtle
graphics window</td>
</tr>
</tbody>
</table>
<p>Set title of turtle window to <em>titlestring</em>.</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s2">&quot;Welcome to the turtle zoo!&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="the-public-classes-of-the-module-turtle">
<h2>24.5.5. The public classes of the module <a class="reference internal" href="#module-turtle" title="turtle: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a><a class="headerlink" href="#the-public-classes-of-the-module-turtle" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="turtle.RawTurtle">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">RawTurtle</code><span class="sig-paren">(</span><em>canvas</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.RawTurtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.RawPen">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">RawPen</code><span class="sig-paren">(</span><em>canvas</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.RawPen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>canvas</strong> – a <code class="xref py py-class docutils literal notranslate"><span class="pre">Tkinter.Canvas</span></code>, a <a class="reference internal" href="#turtle.ScrolledCanvas" title="turtle.ScrolledCanvas"><code class="xref py py-class docutils literal notranslate"><span class="pre">ScrolledCanvas</span></code></a> or a
<a class="reference internal" href="#turtle.TurtleScreen" title="turtle.TurtleScreen"><code class="xref py py-class docutils literal notranslate"><span class="pre">TurtleScreen</span></code></a></td>
</tr>
</tbody>
</table>
<p>Create a turtle.  The turtle has all methods described above as “methods of
Turtle/RawTurtle”.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Turtle">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Turtle</code><a class="headerlink" href="#turtle.Turtle" title="Permalink to this definition">¶</a></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 class="xref py py-class docutils literal notranslate"><span class="pre">Screen</span></code></a> object created automatically when needed for the first time.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.TurtleScreen">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">TurtleScreen</code><span class="sig-paren">(</span><em>cv</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.TurtleScreen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>cv</strong> – a <code class="xref py py-class docutils literal notranslate"><span class="pre">Tkinter.Canvas</span></code></td>
</tr>
</tbody>
</table>
<p>Provides screen oriented methods like <code class="xref py py-func docutils literal notranslate"><span class="pre">setbg()</span></code> etc. that are described
above.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Screen">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Screen</code><a class="headerlink" href="#turtle.Screen" title="Permalink to this definition">¶</a></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="class">
<dt id="turtle.ScrolledCanvas">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">ScrolledCanvas</code><span class="sig-paren">(</span><em>master</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.ScrolledCanvas" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>master</strong> – some Tkinter widget to contain the ScrolledCanvas, i.e.
a Tkinter-canvas with scrollbars added</td>
</tr>
</tbody>
</table>
<p>Used by class Screen, which thus automatically provides a ScrolledCanvas as
playground for the turtles.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Shape">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Shape</code><span class="sig-paren">(</span><em>type_</em>, <em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.Shape" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>type_</strong> – one of the strings “polygon”, “image”, “compound”</td>
</tr>
</tbody>
</table>
<p>Data structure modeling shapes.  The pair <code class="docutils literal notranslate"><span class="pre">(type_,</span> <span class="pre">data)</span></code> must follow this
specification:</p>
<table border="1" class="docutils">
<colgroup>
<col width="16%" />
<col width="84%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head"><em>type_</em></th>
<th class="head"><em>data</em></th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>“polygon”</td>
<td>a polygon-tuple, i.e. a tuple of pairs of coordinates</td>
</tr>
<tr class="row-odd"><td>“image”</td>
<td>an image  (in this form only used internally!)</td>
</tr>
<tr class="row-even"><td>“compound”</td>
<td><code class="docutils literal notranslate"><span class="pre">None</span></code> (a compound shape has to be constructed using the
<a class="reference internal" href="#turtle.Shape.addcomponent" title="turtle.Shape.addcomponent"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addcomponent()</span></code></a> method)</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="turtle.Shape.addcomponent">
<code class="descname">addcomponent</code><span class="sig-paren">(</span><em>poly</em>, <em>fill</em>, <em>outline=None</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.Shape.addcomponent" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last 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>
</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),(</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">),(</span><span class="mi">0</span><span class="p">,</span><span class="mi">10</span><span class="p">),(</span><span class="o">-</span><span class="mi">10</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">Shape</span><span class="p">(</span><span class="s2">&quot;compound&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly</span><span class="p">,</span> <span class="s2">&quot;red&quot;</span><span class="p">,</span> <span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># ... add more components and then use register_shape()</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="#compoundshapes"><span class="std std-ref">Excursus about the use of compound shapes</span></a>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="turtle.Vec2D">
<em class="property">class </em><code class="descclassname">turtle.</code><code class="descname">Vec2D</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.Vec2D" title="Permalink to this definition">¶</a></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 class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">+</span> <span class="pre">b</span></code> vector addition</li>
<li><code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b</span></code> vector subtraction</li>
<li><code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">b</span></code> inner product</li>
<li><code class="docutils literal notranslate"><span class="pre">k</span> <span class="pre">*</span> <span class="pre">a</span></code> and <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">k</span></code> multiplication with scalar</li>
<li><code class="docutils literal notranslate"><span class="pre">abs(a)</span></code> absolute value of a</li>
<li><code class="docutils literal notranslate"><span class="pre">a.rotate(angle)</span></code> rotation</li>
</ul>
</dd></dl>

</div>
<div class="section" id="help-and-configuration">
<h2>24.5.6. Help and configuration<a class="headerlink" href="#help-and-configuration" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-to-use-help">
<h3>24.5.6.1. How to use help<a class="headerlink" href="#how-to-use-help" title="Permalink to this headline">¶</a></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><p class="first">When using IDLE, tooltips show the signatures and first lines of the
docstrings of typed in function-/method calls.</p>
</li>
<li><p class="first">Calling <a class="reference internal" href="functions.html#help" title="help"><code class="xref py py-func docutils literal notranslate"><span class="pre">help()</span></code></a> on methods or functions displays the docstrings:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">Screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">)</span>
<span class="go">Help on method bgcolor in module turtle:</span>

<span class="go">bgcolor(self, *args) unbound turtle.Screen method</span>
<span class="go">    Set or return backgroundcolor of the TurtleScreen.</span>

<span class="go">    Arguments (if given): a color string or three numbers</span>
<span class="go">    in the range 0..colormode or a 3-tuple of such numbers.</span>


<span class="go">      &gt;&gt;&gt; screen.bgcolor(&quot;orange&quot;)</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor()</span>
<span class="go">      &quot;orange&quot;</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor(0.5,0,0.5)</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor()</span>
<span class="go">      &quot;#800080&quot;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">Turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">)</span>
<span class="go">Help on method penup in module turtle:</span>

<span class="go">penup(self) unbound turtle.Turtle method</span>
<span class="go">    Pull the pen up -- no drawing when moving.</span>

<span class="go">    Aliases: penup | pu | up</span>

<span class="go">    No argument</span>

<span class="go">    &gt;&gt;&gt; turtle.penup()</span>
</pre></div>
</div>
</li>
<li><p class="first">The docstrings of the functions which are derived from methods have a modified
form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">bgcolor</span><span class="p">)</span>
<span class="go">Help on function bgcolor in module turtle:</span>

<span class="go">bgcolor(*args)</span>
<span class="go">    Set or return backgroundcolor of the TurtleScreen.</span>

<span class="go">    Arguments (if given): a color string or three numbers</span>
<span class="go">    in the range 0..colormode or a 3-tuple of such numbers.</span>

<span class="go">    Example::</span>

<span class="go">      &gt;&gt;&gt; bgcolor(&quot;orange&quot;)</span>
<span class="go">      &gt;&gt;&gt; bgcolor()</span>
<span class="go">      &quot;orange&quot;</span>
<span class="go">      &gt;&gt;&gt; bgcolor(0.5,0,0.5)</span>
<span class="go">      &gt;&gt;&gt; bgcolor()</span>
<span class="go">      &quot;#800080&quot;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">penup</span><span class="p">)</span>
<span class="go">Help on function penup in module turtle:</span>

<span class="go">penup()</span>
<span class="go">    Pull the pen up -- no drawing when moving.</span>

<span class="go">    Aliases: penup | pu | up</span>

<span class="go">    No argument</span>

<span class="go">    Example:</span>
<span class="go">    &gt;&gt;&gt; penup()</span>
</pre></div>
</div>
</li>
</ul>
<p>These modified docstrings are created automatically together with the function
definitions that are derived from the methods at import time.</p>
</div>
<div class="section" id="translation-of-docstrings-into-different-languages">
<h3>24.5.6.2. Translation of docstrings into different languages<a class="headerlink" href="#translation-of-docstrings-into-different-languages" title="Permalink to this headline">¶</a></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="function">
<dt id="turtle.write_docstringdict">
<code class="descclassname">turtle.</code><code class="descname">write_docstringdict</code><span class="sig-paren">(</span><em>filename=&quot;turtle_docstringdict&quot;</em><span class="sig-paren">)</span><a class="headerlink" href="#turtle.write_docstringdict" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> – a string, used as filename</td>
</tr>
</tbody>
</table>
<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 class="file docutils literal notranslate"><em><span class="pre">filename</span></em><span class="pre">.py</span></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: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a> with online help in your
native language, you have to translate the docstrings and save the resulting
file as e.g. <code class="file docutils literal notranslate"><span class="pre">turtle_docstringdict_german.py</span></code>.</p>
<p>If you have an appropriate entry in your <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></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&#37;&#52;&#48;aon&#46;at">glingl<span>&#64;</span>aon<span>&#46;</span>at</a>.)</p>
</div>
<div class="section" id="how-to-configure-screen-and-turtles">
<h3>24.5.6.3. How to configure Screen and Turtles<a class="headerlink" href="#how-to-configure-screen-and-turtles" title="Permalink to this headline">¶</a></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 class="docutils literal notranslate"><span class="pre">turtle.cfg</span></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 turtle.cfg:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">width</span> <span class="o">=</span> <span class="mf">0.5</span>
<span class="n">height</span> <span class="o">=</span> <span class="mf">0.75</span>
<span class="n">leftright</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">topbottom</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">canvwidth</span> <span class="o">=</span> <span class="mi">400</span>
<span class="n">canvheight</span> <span class="o">=</span> <span class="mi">300</span>
<span class="n">mode</span> <span class="o">=</span> <span class="n">standard</span>
<span class="n">colormode</span> <span class="o">=</span> <span class="mf">1.0</span>
<span class="n">delay</span> <span class="o">=</span> <span class="mi">10</span>
<span class="n">undobuffersize</span> <span class="o">=</span> <span class="mi">1000</span>
<span class="n">shape</span> <span class="o">=</span> <span class="n">classic</span>
<span class="n">pencolor</span> <span class="o">=</span> <span class="n">black</span>
<span class="n">fillcolor</span> <span class="o">=</span> <span class="n">black</span>
<span class="n">resizemode</span> <span class="o">=</span> <span class="n">noresize</span>
<span class="n">visible</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">language</span> <span class="o">=</span> <span class="n">english</span>
<span class="n">exampleturtle</span> <span class="o">=</span> <span class="n">turtle</span>
<span class="n">examplescreen</span> <span class="o">=</span> <span class="n">screen</span>
<span class="n">title</span> <span class="o">=</span> <span class="n">Python</span> <span class="n">Turtle</span> <span class="n">Graphics</span>
<span class="n">using_IDLE</span> <span class="o">=</span> <span class="kc">False</span>
</pre></div>
</div>
<p>Short explanation of selected entries:</p>
<ul class="simple">
<li>The first four lines correspond to the arguments of the <code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.setup()</span></code>
method.</li>
<li>Line 5 and 6 correspond to the arguments of the method
<code class="xref py py-meth docutils literal notranslate"><span class="pre">Screen.screensize()</span></code>.</li>
<li><em>shape</em> can be any of the built-in shapes, e.g: arrow, turtle, etc.  For more
info try <code class="docutils literal notranslate"><span class="pre">help(shape)</span></code>.</li>
<li>If you want to use no fillcolor (i.e. make the turtle transparent), you have
to write <code class="docutils literal notranslate"><span class="pre">fillcolor</span> <span class="pre">=</span> <span class="pre">&quot;&quot;</span></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 class="docutils literal notranslate"><span class="pre">resizemode</span> <span class="pre">=</span>
<span class="pre">auto</span></code>.</li>
<li>If you set e.g. <code class="docutils literal notranslate"><span class="pre">language</span> <span class="pre">=</span> <span class="pre">italian</span></code> the docstringdict
<code class="file docutils literal notranslate"><span class="pre">turtle_docstringdict_italian.py</span></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: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></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 class="docutils literal notranslate"><span class="pre">True</span></code> if you regularly work with IDLE and its -n
switch (“no subprocess”).  This will prevent <a class="reference internal" href="#turtle.exitonclick" title="turtle.exitonclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">exitonclick()</span></code></a> to enter the
mainloop.</li>
</ul>
<p>There can be a <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file in the directory where <a class="reference internal" href="#module-turtle" title="turtle: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></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 class="file docutils literal notranslate"><span class="pre">Demo/turtle</span></code> directory contains a <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></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>
</div>
</div>
<div class="section" id="demo-scripts">
<h2>24.5.7. Demo scripts<a class="headerlink" href="#demo-scripts" title="Permalink to this headline">¶</a></h2>
<p>There is a set of demo scripts in the turtledemo directory located in the
<code class="file docutils literal notranslate"><span class="pre">Demo/turtle</span></code> directory in the source distribution.</p>
<p>It contains:</p>
<ul class="simple">
<li>a set of 15 demo scripts demonstrating different features of the new module
<a class="reference internal" href="#module-turtle" title="turtle: Turtle graphics for Tk"><code class="xref py py-mod docutils literal notranslate"><span class="pre">turtle</span></code></a></li>
<li>a demo viewer <code class="file docutils literal notranslate"><span class="pre">turtleDemo.py</span></code> which can be used to view the sourcecode
of the scripts and run them at the same time. 14 of the examples can be
accessed via the Examples menu; all of them can also be run standalone.</li>
<li>The example <code class="file docutils literal notranslate"><span class="pre">turtledemo_two_canvases.py</span></code> demonstrates the simultaneous
use of two canvases with the turtle module.  Therefore it only can be run
standalone.</li>
<li>There is a <code class="file docutils literal notranslate"><span class="pre">turtle.cfg</span></code> file in this directory, which also serves as an
example for how to write and use such files.</li>
</ul>
<p>The demoscripts are:</p>
<table border="1" class="docutils">
<colgroup>
<col width="23%" />
<col width="43%" />
<col width="33%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Description</th>
<th class="head">Features</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>bytedesign</td>
<td>complex classical
turtlegraphics pattern</td>
<td><a class="reference internal" href="#turtle.tracer" title="turtle.tracer"><code class="xref py py-func docutils literal notranslate"><span class="pre">tracer()</span></code></a>, delay,
<a class="reference internal" href="#turtle.update" title="turtle.update"><code class="xref py py-func docutils literal notranslate"><span class="pre">update()</span></code></a></td>
</tr>
<tr class="row-odd"><td>chaos</td>
<td>graphs Verhulst dynamics,
shows that computer’s
computations can generate
results sometimes against the
common sense expectations</td>
<td>world coordinates</td>
</tr>
<tr class="row-even"><td>clock</td>
<td>analog clock showing time
of your computer</td>
<td>turtles as clock’s
hands, ontimer</td>
</tr>
<tr class="row-odd"><td>colormixer</td>
<td>experiment with r, g, b</td>
<td><a class="reference internal" href="#turtle.ondrag" title="turtle.ondrag"><code class="xref py py-func docutils literal notranslate"><span class="pre">ondrag()</span></code></a></td>
</tr>
<tr class="row-even"><td>fractalcurves</td>
<td>Hilbert &amp; Koch curves</td>
<td>recursion</td>
</tr>
<tr class="row-odd"><td>lindenmayer</td>
<td>ethnomathematics
(indian kolams)</td>
<td>L-System</td>
</tr>
<tr class="row-even"><td>minimal_hanoi</td>
<td>Towers of Hanoi</td>
<td>Rectangular Turtles
as Hanoi discs
(shape, shapesize)</td>
</tr>
<tr class="row-odd"><td>paint</td>
<td>super minimalistic
drawing program</td>
<td><a class="reference internal" href="#turtle.onclick" title="turtle.onclick"><code class="xref py py-func docutils literal notranslate"><span class="pre">onclick()</span></code></a></td>
</tr>
<tr class="row-even"><td>peace</td>
<td>elementary</td>
<td>turtle: appearance
and animation</td>
</tr>
<tr class="row-odd"><td>penrose</td>
<td>aperiodic tiling with
kites and darts</td>
<td><a class="reference internal" href="#turtle.stamp" title="turtle.stamp"><code class="xref py py-func docutils literal notranslate"><span class="pre">stamp()</span></code></a></td>
</tr>
<tr class="row-even"><td>planet_and_moon</td>
<td>simulation of
gravitational system</td>
<td>compound shapes,
<a class="reference internal" href="#turtle.Vec2D" title="turtle.Vec2D"><code class="xref py py-class docutils literal notranslate"><span class="pre">Vec2D</span></code></a></td>
</tr>
<tr class="row-odd"><td>tree</td>
<td>a (graphical) breadth
first tree (using generators)</td>
<td><a class="reference internal" href="#turtle.clone" title="turtle.clone"><code class="xref py py-func docutils literal notranslate"><span class="pre">clone()</span></code></a></td>
</tr>
<tr class="row-even"><td>wikipedia</td>
<td>a pattern from the wikipedia
article on turtle graphics</td>
<td><a class="reference internal" href="#turtle.clone" title="turtle.clone"><code class="xref py py-func docutils literal notranslate"><span class="pre">clone()</span></code></a>,
<a class="reference internal" href="#turtle.undo" title="turtle.undo"><code class="xref py py-func docutils literal notranslate"><span class="pre">undo()</span></code></a></td>
</tr>
<tr class="row-odd"><td>yinyang</td>
<td>another elementary example</td>
<td><a class="reference internal" href="#turtle.circle" title="turtle.circle"><code class="xref py py-func docutils literal notranslate"><span class="pre">circle()</span></code></a></td>
</tr>
</tbody>
</table>
<p>Have fun!</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">24.5. <code class="docutils literal notranslate"><span class="pre">turtle</span></code> — Turtle graphics for Tk</a><ul>
<li><a class="reference internal" href="#introduction">24.5.1. Introduction</a></li>
<li><a class="reference internal" href="#overview-over-available-turtle-and-screen-methods">24.5.2. Overview over available Turtle and Screen methods</a><ul>
<li><a class="reference internal" href="#turtle-methods">24.5.2.1. Turtle methods</a></li>
<li><a class="reference internal" href="#methods-of-turtlescreen-screen">24.5.2.2. Methods of TurtleScreen/Screen</a></li>
</ul>
</li>
<li><a class="reference internal" href="#methods-of-rawturtle-turtle-and-corresponding-functions">24.5.3. Methods of RawTurtle/Turtle and corresponding functions</a><ul>
<li><a class="reference internal" href="#turtle-motion">24.5.3.1. Turtle motion</a></li>
<li><a class="reference internal" href="#tell-turtle-s-state">24.5.3.2. Tell Turtle’s state</a></li>
<li><a class="reference internal" href="#settings-for-measurement">24.5.3.3. Settings for measurement</a></li>
<li><a class="reference internal" href="#pen-control">24.5.3.4. Pen control</a><ul>
<li><a class="reference internal" href="#drawing-state">24.5.3.4.1. Drawing state</a></li>
<li><a class="reference internal" href="#color-control">24.5.3.4.2. Color control</a></li>
<li><a class="reference internal" href="#filling">24.5.3.4.3. Filling</a></li>
<li><a class="reference internal" href="#more-drawing-control">24.5.3.4.4. More drawing control</a></li>
</ul>
</li>
<li><a class="reference internal" href="#turtle-state">24.5.3.5. Turtle state</a><ul>
<li><a class="reference internal" href="#visibility">24.5.3.5.1. Visibility</a></li>
<li><a class="reference internal" href="#appearance">24.5.3.5.2. Appearance</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-events">24.5.3.6. Using events</a></li>
<li><a class="reference internal" href="#special-turtle-methods">24.5.3.7. Special Turtle methods</a></li>
<li><a class="reference internal" href="#excursus-about-the-use-of-compound-shapes">24.5.3.8. Excursus about the use of compound shapes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#methods-of-turtlescreen-screen-and-corresponding-functions">24.5.4. Methods of TurtleScreen/Screen and corresponding functions</a><ul>
<li><a class="reference internal" href="#window-control">24.5.4.1. Window control</a></li>
<li><a class="reference internal" href="#animation-control">24.5.4.2. Animation control</a></li>
<li><a class="reference internal" href="#using-screen-events">24.5.4.3. Using screen events</a></li>
<li><a class="reference internal" href="#settings-and-special-methods">24.5.4.4. Settings and special methods</a></li>
<li><a class="reference internal" href="#methods-specific-to-screen-not-inherited-from-turtlescreen">24.5.4.5. Methods specific to Screen, not inherited from TurtleScreen</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-public-classes-of-the-module-turtle">24.5.5. The public classes of the module <code class="docutils literal notranslate"><span class="pre">turtle</span></code></a></li>
<li><a class="reference internal" href="#help-and-configuration">24.5.6. Help and configuration</a><ul>
<li><a class="reference internal" href="#how-to-use-help">24.5.6.1. How to use help</a></li>
<li><a class="reference internal" href="#translation-of-docstrings-into-different-languages">24.5.6.2. Translation of docstrings into different languages</a></li>
<li><a class="reference internal" href="#how-to-configure-screen-and-turtles">24.5.6.3. How to configure Screen and Turtles</a></li>
</ul>
</li>
<li><a class="reference internal" href="#demo-scripts">24.5.7. Demo scripts</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="scrolledtext.html"
                        title="previous chapter">24.4. <code class="docutils literal notranslate"><span class="pre">ScrolledText</span></code> — Scrolled Text Widget</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="idle.html"
                        title="next chapter">24.6. IDLE</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/library/turtle.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="idle.html" title="24.6. IDLE"
             >next</a> |</li>
        <li class="right" >
          <a href="scrolledtext.html" title="24.4. ScrolledText — Scrolled Text Widget"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">Python 2.7.18 documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="tk.html" >24. Graphical User Interfaces with Tk</a> &#187;</li> 
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2024, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on November 21, 2024.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.8.5.
    </div>

  </body>
</html>

-=[ KCW uplo4d3r c0ded by cJ_n4p573r ]=-
Ⓒ2017 ҠЄГѦLѦ СүѣЄГ ЩѦГГіѺГՏ