diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..5f4afbb --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,55 @@ +name: Tests + +on: [push, pull_request, workflow_dispatch] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python: ["3.11", "3.12", "3.13", "3.14", "3.15", "3.16"] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + if: matrix.python != '3.16' + with: + python-version: ${{ matrix.python }} + allow-prereleases: true + # Build the recorded development snapshot before 3.16 has binary releases. + - name: Read Python 3.16 source revision + if: matrix.python == '3.16' + id: source + run: | + python3 -c 'import json; print("ref=" + json.load(open("sources/turtle.json"))["versions"]["3.16"]["commit"])' >> "$GITHUB_OUTPUT" + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: matrix.python == '3.16' + with: + repository: python/cpython + ref: ${{ steps.source.outputs.ref }} + path: .cpython + persist-credentials: false + - name: Build Python 3.16 + if: matrix.python == '3.16' + working-directory: .cpython + run: | + sudo apt-get update + sudo apt-get install -y tk-dev + ./configure --prefix="$RUNNER_TEMP/turtle-python" + make -j2 + make install + echo "$RUNNER_TEMP/turtle-python/bin" >> "$GITHUB_PATH" + - name: Install package and test dependencies + run: python3 -m pip install . babel hatchling + - name: Test catalogs, extraction, and turtle integration + run: python3 -m unittest discover -s tests -v + - name: Verify installed shim outside the checkout + working-directory: ${{ runner.temp }} + run: | + python3 -I -c 'import sys, turtle_docstringdict_pl as pl; assert isinstance(pl.docsdict, dict); assert "tkinter" not in sys.modules; assert "babel" not in sys.modules' + python3 -I -c 'import turtle_translations; assert "pl" in turtle_translations.available()' diff --git a/.gitignore b/.gitignore index 6e7ae53..e100939 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Compiled from po/*.po +/turtle_docstringdict_*.py /turtle_translations/*.py !/turtle_translations/__init__.py diff --git a/README.md b/README.md index 984b44a..c8efcd7 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,27 @@ Translations live in gettext catalogs in the `po/` directory. ### Extracting the template -The template is extracted from the `turtle` module of the Python you run the -script with, so use the latest Python version available: +The shared template contains all distinct English docstrings for Python 3.11–3.16. +Regenerate it from the committed source mappings (no Tkinter required): ```console $ python scripts/i18n.py extract -po/turtle.pot: 103 docstrings from Python 3.16.0a0 +po/turtle.pot: 118 distinct docstrings from Python 3.11–3.16 ``` +To refresh the mappings first, use a local CPython checkout with `upstream/3.11` +through `upstream/3.15` and `upstream/main` (3.16): + +```console +$ python scripts/i18n.py extract --cpython ../cpython +``` + +This reads Git objects without switching branches or changing the CPython checkout. +The committed [compatibility report](sources/README.md) records source revisions, +method-level changes, and shared dictionary groups. The analysis covers these +branch snapshots, not every historical patch release. Source indentation is +normalized consistently across Python versions. + ### Adding a language Create a new catalog from the template for your language: @@ -28,9 +41,13 @@ Created: po/ga.po You can now translate it with your tool of choice. +Add `turtle_docstringdict_.py` (with a lowercase language code) to +`tool.check-wheel-contents.toplevel` in `pyproject.toml` so package inspection +expects the new language's generated shim. + ### Updating the catalogs -After re-extracting the template against a newer Python, merge the changes +After refreshing the source mappings and template, merge the changes into the existing catalogs: ```console @@ -47,17 +64,64 @@ that no longer exist in the template rather than keeping them commented out. ```console $ python scripts/i18n.py stats -pl 42/103 translated (40%), 3 fuzzy +pl 0/118 translated (0%), 0 fuzzy ``` ### Compiling -Each PO file compiles to a `turtle_translations/.py` module containing a -`docsdict`, which is what `turtle` loads. The generated modules are built -automatically when the wheel is built, so you normally only need this to test -locally: +Each PO file compiles to a top-level `turtle_docstringdict_.py` shim and +internal version-specific dictionaries under +`turtle_translations//py3.py`. The shim exports `docsdict`, +which is what `turtle` loads. Compilation matches each method's English source +text, omitting untranslated and fuzzy entries so their help stays English. +One PO entry can serve multiple methods and versions; extracted comments identify +each use. All English variants remain in the shared catalog. + +The generated modules are built automatically when the wheel is built, so you +normally only need this to test locally: ```console $ python scripts/i18n.py compile -Compiled: turtle_translations/pl.py +Compiled: turtle_translations/pl/py311.py +Compiled: turtle_translations/pl/py312.py +Compiled: turtle_translations/pl/py313.py +Compiled: turtle_translations/pl/py314.py +Compiled: turtle_docstringdict_pl.py ``` + +The shim uses `sys.version_info[:2]`: + +| Python | Dictionary | +| --- | --- | +| 3.10 and older | 3.11 | +| 3.11 | 3.11 | +| 3.12 | 3.12 | +| 3.13 | 3.13 | +| 3.14 and newer | Shared 3.14–3.16 | + +Python 3.11–3.16 is supported. The older-version fallback does not extend the +package's `>=3.11` installation requirement. Future Python versions use the newest +dictionary until their sources are analyzed. No runtime dependencies are needed +to import the shim; builds require Babel and Hatchling, but neither Tkinter nor a +CPython checkout. `turtle_translations.available()` lists language codes. + +## Using translations + +Install the package and place a `turtle.cfg` file in your working directory: + +```ini +language = pl +``` + +Start a fresh Python process there and import `turtle`. Its class and module-level +help will use the available translations. + +## Tests + +Install Babel and Hatchling and run: + +```console +$ python -m unittest discover -s tests -v +``` + +Runtime integration tests require Tkinter, but do not create a window. diff --git a/po/pl.po b/po/pl.po index 7e87434..3bf7106 100644 --- a/po/pl.po +++ b/po/pl.po @@ -5,10 +5,10 @@ # msgid "" msgstr "" -"Project-Id-Version: turtle-translations 3.16.0a0\n" +"Project-Id-Version: turtle-translations 3.11–3.16\n" "Report-Msgid-Bugs-To: https://github.com/python/turtle-translations/issues\n" -"POT-Creation-Date: 2026-09-12 10:34+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"POT-Creation-Date: 2026-09-22 10:23+0200\n" +"PO-Revision-Date: 2026-09-22 07:19+0000\n" "Last-Translator: FULL NAME \n" "Language: pl\n" "Language-Team: pl \n" @@ -18,21 +18,21 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.18.0\n" -#. turtle.RawTurtle +#. turtle.RawTurtle (Python 3.11–3.16) msgid "" "Animation part of the RawTurtle.\n" "Puts RawTurtle upon a TurtleScreen and provides tools for\n" "its animation.\n" msgstr "" -#. turtle.Screen +#. turtle.Screen (Python 3.11–3.16) msgid "" "Return the singleton screen object.\n" "If none exists at the moment, create a new one and return it,\n" "else return the existing one." msgstr "" -#. turtle.ScrolledCanvas +#. turtle.ScrolledCanvas (Python 3.11–3.16) msgid "" "Modeled after the scrolled canvas class from Grayons's Tkinter book.\n" "\n" @@ -40,7 +40,7 @@ msgid "" "using turtle graphics functions or the Turtle class.\n" msgstr "" -#. turtle.Shape +#. turtle.Shape (Python 3.11–3.16) msgid "" "Data structure modeling shapes.\n" "\n" @@ -49,7 +49,7 @@ msgid "" "an image or a list constructed using the addcomponent method.\n" msgstr "" -#. turtle.Terminator +#. turtle.Terminator (Python 3.11–3.16) msgid "" "Will be raised in TurtleScreen.update, if _RUNNING becomes False.\n" "\n" @@ -57,7 +57,7 @@ msgid "" "Main purpose: use in the Demo-Viewer turtle.Demo.py.\n" msgstr "" -#. turtle.Turtle +#. turtle.Turtle (Python 3.11–3.16) msgid "" "RawTurtle auto-creating (scrolled) canvas.\n" "\n" @@ -65,7 +65,7 @@ msgid "" "Turtle method is called a TurtleScreen object is automatically created.\n" msgstr "" -#. turtle.Turtle.back +#. turtle.Turtle.back (Python 3.13–3.16) msgid "" "Move the turtle backward by distance.\n" "\n" @@ -85,7 +85,7 @@ msgid "" "(-30.00,0.00)\n" msgstr "" -#. turtle.Turtle.begin_fill +#. turtle.Turtle.begin_fill (Python 3.11–3.16) msgid "" "Called just before drawing a shape to be filled.\n" "\n" @@ -98,7 +98,7 @@ msgid "" ">>> turtle.end_fill()\n" msgstr "" -#. turtle.Turtle.begin_poly +#. turtle.Turtle.begin_poly (Python 3.11–3.16) msgid "" "Start recording the vertices of a polygon.\n" "\n" @@ -111,7 +111,7 @@ msgid "" ">>> turtle.begin_poly()\n" msgstr "" -#. turtle.Turtle.circle +#. turtle.Turtle.circle (Python 3.11–3.16) msgid "" "Draw a circle with given radius.\n" "\n" @@ -143,7 +143,7 @@ msgid "" ">>> turtle.circle(120, 180) # semicircle\n" msgstr "" -#. turtle.Turtle.clear +#. turtle.Turtle.clear (Python 3.11–3.16) msgid "" "Delete the turtle's drawings from the screen. Do not move turtle.\n" "\n" @@ -157,7 +157,7 @@ msgid "" ">>> turtle.clear()\n" msgstr "" -#. turtle.Turtle.clearstamp +#. turtle.Turtle.clearstamp (Python 3.11–3.16) msgid "" "Delete stamp with given stampid\n" "\n" @@ -171,7 +171,7 @@ msgid "" ">>> turtle.clearstamp(astamp)\n" msgstr "" -#. turtle.Turtle.clearstamps +#. turtle.Turtle.clearstamps (Python 3.11–3.16) msgid "" "Delete all or first/last n of turtle's stamps.\n" "\n" @@ -191,7 +191,7 @@ msgid "" ">>> turtle.clearstamps()\n" msgstr "" -#. turtle.Turtle.clone +#. turtle.Turtle.clone (Python 3.11–3.16) msgid "" "Create and return a clone of the turtle.\n" "\n" @@ -205,7 +205,7 @@ msgid "" "joe = mick.clone()\n" msgstr "" -#. turtle.Turtle.color +#. turtle.Turtle.color (Python 3.13–3.16) msgid "" "Return or set the pencolor and fillcolor.\n" "\n" @@ -237,7 +237,7 @@ msgid "" "((40.0, 80.0, 120.0), (160.0, 200.0, 240.0))\n" msgstr "" -#. turtle.Turtle.degrees +#. turtle.Turtle.degrees (Python 3.11–3.16) msgid "" "Set angle measurement units to degrees.\n" "\n" @@ -261,7 +261,7 @@ msgid "" "\n" msgstr "" -#. turtle.Turtle.distance +#. turtle.Turtle.distance (Python 3.13–3.16) msgid "" "Return the distance from the turtle to (x,y) in turtle step units.\n" "\n" @@ -285,7 +285,7 @@ msgid "" "77.0\n" msgstr "" -#. turtle.Turtle.dot +#. turtle.Turtle.dot (Python 3.11–3.16) msgid "" "Draw a dot with diameter size, using color.\n" "\n" @@ -301,8 +301,8 @@ msgid "" ">>> turtle.fd(50); turtle.dot(20, \"blue\"); turtle.fd(50)\n" msgstr "" -#. turtle.Turtle.down -#. turtle.Turtle.pendown +#. turtle.Turtle.down (Python 3.11–3.16) +#. turtle.Turtle.pendown (Python 3.11–3.16) msgid "" "Pull the pen down -- drawing when moving.\n" "\n" @@ -314,7 +314,7 @@ msgid "" ">>> turtle.pendown()\n" msgstr "" -#. turtle.Turtle.end_fill +#. turtle.Turtle.end_fill (Python 3.11–3.16) msgid "" "Fill the shape drawn after the call begin_fill().\n" "\n" @@ -327,7 +327,7 @@ msgid "" ">>> turtle.end_fill()\n" msgstr "" -#. turtle.Turtle.end_poly +#. turtle.Turtle.end_poly (Python 3.11–3.16) msgid "" "Stop recording the vertices of a polygon.\n" "\n" @@ -340,7 +340,7 @@ msgid "" ">>> turtle.end_poly()\n" msgstr "" -#. turtle.Turtle.fill +#. turtle.Turtle.fill (Python 3.14–3.16) msgid "" "A context manager for filling a shape.\n" "\n" @@ -353,7 +353,7 @@ msgid "" "... turtle.circle(60)\n" msgstr "" -#. turtle.Turtle.fillcolor +#. turtle.Turtle.fillcolor (Python 3.13–3.16) msgid "" "Return or set the fillcolor.\n" "\n" @@ -388,7 +388,7 @@ msgid "" "(255.0, 255.0, 255.0)\n" msgstr "" -#. turtle.Turtle.filling +#. turtle.Turtle.filling (Python 3.11–3.16) msgid "" "Return fillstate (True if filling, False else).\n" "\n" @@ -402,7 +402,7 @@ msgid "" "... turtle.pensize(3)\n" msgstr "" -#. turtle.Turtle.forward +#. turtle.Turtle.forward (Python 3.13–3.16) msgid "" "Move the turtle forward by the specified distance.\n" "\n" @@ -425,7 +425,7 @@ msgid "" "(-50.00,0.00)\n" msgstr "" -#. turtle.Turtle.get_poly +#. turtle.Turtle.get_poly (Python 3.11–3.16) msgid "" "Return the lastly recorded polygon.\n" "\n" @@ -436,7 +436,7 @@ msgid "" ">>> turtle.register_shape(\"myFavouriteShape\", p)\n" msgstr "" -#. turtle.Turtle.get_shapepoly +#. turtle.Turtle.get_shapepoly (Python 3.11–3.16) msgid "" "Return the current shape polygon as tuple of coordinate pairs.\n" "\n" @@ -450,8 +450,8 @@ msgid "" "\n" msgstr "" -#. turtle.Turtle.getpen -#. turtle.Turtle.getturtle +#. turtle.Turtle.getpen (Python 3.11–3.16) +#. turtle.Turtle.getturtle (Python 3.11–3.16) msgid "" "Return the Turtleobject itself.\n" "\n" @@ -468,7 +468,7 @@ msgid "" "[]\n" msgstr "" -#. turtle.Turtle.getscreen +#. turtle.Turtle.getscreen (Python 3.11–3.16) msgid "" "Return the TurtleScreen object, the turtle is drawing on.\n" "\n" @@ -484,7 +484,7 @@ msgid "" ">>> ts.bgcolor(\"pink\")\n" msgstr "" -#. turtle.Turtle.goto +#. turtle.Turtle.goto (Python 3.13–3.16) msgid "" "Move turtle to an absolute position.\n" "\n" @@ -516,7 +516,7 @@ msgid "" "(0.00,0.00)\n" msgstr "" -#. turtle.Turtle.heading +#. turtle.Turtle.heading (Python 3.11–3.16) msgid "" "Return the turtle's current heading.\n" "\n" @@ -528,7 +528,7 @@ msgid "" "67.0\n" msgstr "" -#. turtle.Turtle.hideturtle +#. turtle.Turtle.hideturtle (Python 3.11–3.16) msgid "" "Makes the turtle invisible.\n" "\n" @@ -544,7 +544,7 @@ msgid "" ">>> turtle.hideturtle()\n" msgstr "" -#. turtle.Turtle.home +#. turtle.Turtle.home (Python 3.11–3.16) msgid "" "Move turtle to the origin - coordinates (0,0).\n" "\n" @@ -557,7 +557,7 @@ msgid "" ">>> turtle.home()\n" msgstr "" -#. turtle.Turtle.isdown +#. turtle.Turtle.isdown (Python 3.11–3.16) msgid "" "Return True if pen is down, False if it's up.\n" "\n" @@ -572,7 +572,7 @@ msgid "" "True\n" msgstr "" -#. turtle.Turtle.isvisible +#. turtle.Turtle.isvisible (Python 3.12–3.16) msgid "" "Return True if the Turtle is shown, False if it's hidden.\n" "\n" @@ -584,7 +584,7 @@ msgid "" "False\n" msgstr "" -#. turtle.Turtle.left +#. turtle.Turtle.left (Python 3.11–3.16) msgid "" "Turn turtle left by angle units.\n" "\n" @@ -605,7 +605,7 @@ msgid "" "67.0\n" msgstr "" -#. turtle.Turtle.onclick +#. turtle.Turtle.onclick (Python 3.11–3.16) msgid "" "Bind fun to mouse-click event on this turtle on canvas.\n" "\n" @@ -625,7 +625,7 @@ msgid "" ">>> onclick(None) # event-binding will be removed\n" msgstr "" -#. turtle.Turtle.ondrag +#. turtle.Turtle.ondrag (Python 3.11–3.16) msgid "" "Bind fun to mouse-move event on this turtle on canvas.\n" "\n" @@ -645,7 +645,7 @@ msgid "" "down).\n" msgstr "" -#. turtle.Turtle.onrelease +#. turtle.Turtle.onrelease (Python 3.11–3.16) msgid "" "Bind fun to mouse-button-release event on this turtle on canvas.\n" "\n" @@ -669,7 +669,7 @@ msgid "" "transparent.\n" msgstr "" -#. turtle.Turtle.pen +#. turtle.Turtle.pen (Python 3.11–3.16) #, python-brace-format msgid "" "Return or set the pen's attributes.\n" @@ -719,7 +719,7 @@ msgid "" "'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n" msgstr "" -#. turtle.Turtle.pencolor +#. turtle.Turtle.pencolor (Python 3.13–3.16) msgid "" "Return or set the pencolor.\n" "\n" @@ -754,7 +754,7 @@ msgid "" "(50.0, 193.0, 143.0)\n" msgstr "" -#. turtle.Turtle.pensize +#. turtle.Turtle.pensize (Python 3.11–3.16) msgid "" "Set or return the line thickness.\n" "\n" @@ -774,7 +774,7 @@ msgid "" ">>> turtle.pensize(10) # from here on lines of width 10 are drawn\n" msgstr "" -#. turtle.Turtle.penup +#. turtle.Turtle.penup (Python 3.11–3.16) msgid "" "Pull the pen up -- no drawing when moving.\n" "\n" @@ -786,7 +786,7 @@ msgid "" ">>> turtle.penup()\n" msgstr "" -#. turtle.Turtle.poly +#. turtle.Turtle.poly (Python 3.14–3.16) msgid "" "A context manager for recording the vertices of a polygon.\n" "\n" @@ -802,7 +802,7 @@ msgid "" ">>> turtle.forward(100)\n" msgstr "" -#. turtle.Turtle.position +#. turtle.Turtle.position (Python 3.11–3.16) msgid "" "Return the turtle's current location (x,y), as a Vec2D-vector.\n" "\n" @@ -815,7 +815,7 @@ msgid "" "(0.00, 240.00)\n" msgstr "" -#. turtle.Turtle.radians +#. turtle.Turtle.radians (Python 3.11–3.16) msgid "" "Set the angle measurement units to radians.\n" "\n" @@ -829,7 +829,7 @@ msgid "" "1.5707963267948966\n" msgstr "" -#. turtle.Turtle.reset +#. turtle.Turtle.reset (Python 3.11–3.16) msgid "" "Delete the turtle's drawings and restore its default values.\n" "\n" @@ -850,7 +850,7 @@ msgid "" "0.0\n" msgstr "" -#. turtle.Turtle.resizemode +#. turtle.Turtle.resizemode (Python 3.11–3.16) msgid "" "Set resizemode to one of the values: \"auto\", \"user\", \"noresize\".\n" "\n" @@ -874,7 +874,7 @@ msgid "" "'noresize'\n" msgstr "" -#. turtle.Turtle.right +#. turtle.Turtle.right (Python 3.11–3.16) msgid "" "Turn turtle right by angle units.\n" "\n" @@ -895,7 +895,7 @@ msgid "" "337.0\n" msgstr "" -#. turtle.Turtle.setheading +#. turtle.Turtle.setheading (Python 3.11–3.16) msgid "" "Set the orientation of the turtle to to_angle.\n" "\n" @@ -920,7 +920,7 @@ msgid "" "90\n" msgstr "" -#. turtle.Turtle.setundobuffer +#. turtle.Turtle.setundobuffer (Python 3.11–3.16) msgid "" "Set or disable undobuffer.\n" "\n" @@ -936,7 +936,7 @@ msgid "" ">>> turtle.setundobuffer(42)\n" msgstr "" -#. turtle.Turtle.setx +#. turtle.Turtle.setx (Python 3.11–3.16) msgid "" "Set the turtle's first coordinate to x\n" "\n" @@ -954,7 +954,7 @@ msgid "" "(10.00, 240.00)\n" msgstr "" -#. turtle.Turtle.sety +#. turtle.Turtle.sety (Python 3.11–3.16) msgid "" "Set the turtle's second coordinate to y\n" "\n" @@ -972,7 +972,7 @@ msgid "" "(0.00, -10.00)\n" msgstr "" -#. turtle.Turtle.shape +#. turtle.Turtle.shape (Python 3.11–3.16) msgid "" "Set turtle shape to shape with given name / return current shapename.\n" "\n" @@ -994,7 +994,7 @@ msgid "" "'turtle'\n" msgstr "" -#. turtle.Turtle.shapesize +#. turtle.Turtle.shapesize (Python 3.11–3.16) msgid "" "Set/return turtle's stretchfactors/outline. Set resizemode to \"user\".\n" "\n" @@ -1017,7 +1017,7 @@ msgid "" ">>> turtle.shapesize(outline=8)\n" msgstr "" -#. turtle.Turtle.shapetransform +#. turtle.Turtle.shapetransform (Python 3.11–3.16) msgid "" "Set or return the current transformation matrix of the turtle shape.\n" "\n" @@ -1039,7 +1039,7 @@ msgid "" "(4.0, -1.0, -0.0, 2.0)\n" msgstr "" -#. turtle.Turtle.shearfactor +#. turtle.Turtle.shearfactor (Python 3.11–3.16) msgid "" "Set or return the current shearfactor.\n" "\n" @@ -1060,7 +1060,7 @@ msgid "" ">>> 0.5\n" msgstr "" -#. turtle.Turtle.showturtle +#. turtle.Turtle.showturtle (Python 3.11–3.16) msgid "" "Makes the turtle visible.\n" "\n" @@ -1073,7 +1073,7 @@ msgid "" ">>> turtle.showturtle()\n" msgstr "" -#. turtle.Turtle.speed +#. turtle.Turtle.speed (Python 3.11–3.16) msgid "" "Return or set the turtle's speed.\n" "\n" @@ -1102,7 +1102,7 @@ msgid "" ">>> turtle.speed(3)\n" msgstr "" -#. turtle.Turtle.stamp +#. turtle.Turtle.stamp (Python 3.11–3.16) msgid "" "Stamp a copy of the turtleshape onto the canvas and return its id.\n" "\n" @@ -1119,7 +1119,7 @@ msgid "" ">>> turtle.fd(50)\n" msgstr "" -#. turtle.Turtle.teleport +#. turtle.Turtle.teleport (Python 3.12–3.16) msgid "" "Instantly move turtle to an absolute position.\n" "\n" @@ -1156,7 +1156,7 @@ msgid "" "(20.00,30.00)\n" msgstr "" -#. turtle.Turtle.tilt +#. turtle.Turtle.tilt (Python 3.11–3.16) msgid "" "Rotate the turtleshape by angle.\n" "\n" @@ -1175,7 +1175,7 @@ msgid "" ">>> turtle.fd(50)\n" msgstr "" -#. turtle.Turtle.tiltangle +#. turtle.Turtle.tiltangle (Python 3.13–3.16) msgid "" "Set or return the current tilt-angle.\n" "\n" @@ -1205,7 +1205,7 @@ msgid "" ">>> turtle.fd(50)\n" msgstr "" -#. turtle.Turtle.towards +#. turtle.Turtle.towards (Python 3.11–3.16) msgid "" "Return the angle of the line from the turtle's position to (x, y).\n" "\n" @@ -1229,7 +1229,7 @@ msgid "" "225.0\n" msgstr "" -#. turtle.Turtle.undo +#. turtle.Turtle.undo (Python 3.11–3.16) msgid "" "undo (repeatedly) the last turtle action.\n" "\n" @@ -1248,7 +1248,7 @@ msgid "" "...\n" msgstr "" -#. turtle.Turtle.undobufferentries +#. turtle.Turtle.undobufferentries (Python 3.11–3.16) msgid "" "Return count of entries in the undobuffer.\n" "\n" @@ -1259,7 +1259,7 @@ msgid "" "... undo()\n" msgstr "" -#. turtle.Turtle.write +#. turtle.Turtle.write (Python 3.11–3.16) msgid "" "Write text at the current turtle position.\n" "\n" @@ -1280,7 +1280,7 @@ msgid "" ">>> turtle.write((0,0), True)\n" msgstr "" -#. turtle.Turtle.xcor +#. turtle.Turtle.xcor (Python 3.12–3.16) msgid "" "Return the turtle's x coordinate.\n" "\n" @@ -1294,7 +1294,7 @@ msgid "" "50.0\n" msgstr "" -#. turtle.Turtle.ycor +#. turtle.Turtle.ycor (Python 3.12–3.16) msgid "" "Return the turtle's y coordinate\n" "---\n" @@ -1308,7 +1308,7 @@ msgid "" "86.6025403784\n" msgstr "" -#. turtle.TurtleScreen +#. turtle.TurtleScreen (Python 3.11–3.16) msgid "" "Provides screen oriented methods like bgcolor etc.\n" "\n" @@ -1317,7 +1317,7 @@ msgid "" "which is Tkinter in this case.\n" msgstr "" -#. turtle.Vec2D +#. turtle.Vec2D (Python 3.11–3.16) msgid "" "A 2 dimensional vector class, used as a helper class\n" "for implementing turtle graphics.\n" @@ -1333,7 +1333,7 @@ msgid "" " a.rotate(angle) rotation\n" msgstr "" -#. turtle._Screen.bgcolor +#. turtle._Screen.bgcolor (Python 3.13–3.16) msgid "" "Set or return backgroundcolor of the TurtleScreen.\n" "\n" @@ -1365,7 +1365,7 @@ msgid "" "(128.0, 0.0, 128.0)\n" msgstr "" -#. turtle._Screen.bgpic +#. turtle._Screen.bgpic (Python 3.14–3.16) msgid "" "Set background image or return name of current backgroundimage.\n" "\n" @@ -1384,7 +1384,7 @@ msgid "" "'landscape.gif'\n" msgstr "" -#. turtle._Screen.bye +#. turtle._Screen.bye (Python 3.11–3.16) msgid "" "Shut the turtlegraphics window.\n" "\n" @@ -1392,7 +1392,7 @@ msgid "" ">>> screen.bye()\n" msgstr "" -#. turtle._Screen.clearscreen +#. turtle._Screen.clearscreen (Python 3.11–3.16) msgid "" "Delete all drawings and all turtles from the TurtleScreen.\n" "\n" @@ -1407,7 +1407,7 @@ msgid "" "Note: this method is not available as function.\n" msgstr "" -#. turtle._Screen.colormode +#. turtle._Screen.colormode (Python 3.11–3.16) msgid "" "Return the colormode or set it to 1.0 or 255.\n" "\n" @@ -1423,7 +1423,7 @@ msgid "" ">>> pencolor(240,160,80)\n" msgstr "" -#. turtle._Screen.delay +#. turtle._Screen.delay (Python 3.11–3.16) msgid "" "Return or set the drawing delay in milliseconds.\n" "\n" @@ -1436,7 +1436,7 @@ msgid "" "15\n" msgstr "" -#. turtle._Screen.exitonclick +#. turtle._Screen.exitonclick (Python 3.11–3.16) msgid "" "Go into mainloop until the mouse is clicked.\n" "\n" @@ -1457,7 +1457,7 @@ msgid "" "\n" msgstr "" -#. turtle._Screen.getcanvas +#. turtle._Screen.getcanvas (Python 3.11–3.16) msgid "" "Return the Canvas of this TurtleScreen.\n" "\n" @@ -1469,7 +1469,7 @@ msgid "" "\n" msgstr "" -#. turtle._Screen.getshapes +#. turtle._Screen.getshapes (Python 3.11–3.16) msgid "" "Return a list of names of all currently available turtle shapes.\n" "\n" @@ -1480,7 +1480,7 @@ msgid "" "['arrow', 'blank', 'circle', ... , 'turtle']\n" msgstr "" -#. turtle._Screen.listen +#. turtle._Screen.listen (Python 3.11–3.16) msgid "" "Set focus on TurtleScreen (in order to collect key-events)\n" "\n" @@ -1492,7 +1492,7 @@ msgid "" ">>> screen.listen()\n" msgstr "" -#. turtle._Screen.mainloop +#. turtle._Screen.mainloop (Python 3.11–3.16) msgid "" "Starts event loop - calling Tkinter's mainloop function.\n" "\n" @@ -1507,7 +1507,7 @@ msgid "" "\n" msgstr "" -#. turtle._Screen.mode +#. turtle._Screen.mode (Python 3.11–3.16) msgid "" "Set turtle-mode ('standard', 'logo' or 'world') and perform reset.\n" "\n" @@ -1531,7 +1531,7 @@ msgid "" "'logo'\n" msgstr "" -#. turtle._Screen.no_animation +#. turtle._Screen.no_animation (Python 3.14–3.16) msgid "" "Temporarily turn off auto-updating the screen.\n" "\n" @@ -1545,7 +1545,7 @@ msgid "" "... turtle.circle(50)\n" msgstr "" -#. turtle._Screen.numinput +#. turtle._Screen.numinput (Python 3.11–3.16) msgid "" "Pop up a dialog window for input of a number.\n" "\n" @@ -1565,8 +1565,8 @@ msgid "" "\n" msgstr "" -#. turtle._Screen.onkey -#. turtle._Screen.onkeyrelease +#. turtle._Screen.onkey (Python 3.11–3.16) +#. turtle._Screen.onkeyrelease (Python 3.11–3.16) msgid "" "Bind fun to key-release event of key.\n" "\n" @@ -1591,7 +1591,7 @@ msgid "" "\n" msgstr "" -#. turtle._Screen.onkeypress +#. turtle._Screen.onkeypress (Python 3.11–3.16) msgid "" "Bind fun to key-press event of key if key is given,\n" "or to any key-press-event if no key is given.\n" @@ -1618,7 +1618,7 @@ msgid "" "consequently drawing a hexagon.\n" msgstr "" -#. turtle._Screen.onscreenclick +#. turtle._Screen.onscreenclick (Python 3.11–3.16) msgid "" "Bind fun to mouse-click event on canvas.\n" "\n" @@ -1635,7 +1635,7 @@ msgid "" ">>> screen.onclick(None)\n" msgstr "" -#. turtle._Screen.ontimer +#. turtle._Screen.ontimer (Python 3.11–3.16) msgid "" "Install a timer, which calls fun after t milliseconds.\n" "\n" @@ -1656,7 +1656,7 @@ msgid "" ">>> running = False\n" msgstr "" -#. turtle._Screen.register_shape +#. turtle._Screen.register_shape (Python 3.14–3.16) msgid "" "Adds a turtle shape to TurtleScreen's shapelist.\n" "\n" @@ -1685,7 +1685,7 @@ msgid "" "\n" msgstr "" -#. turtle._Screen.resetscreen +#. turtle._Screen.resetscreen (Python 3.11–3.16) msgid "" "Reset all Turtles on the Screen to their initial state.\n" "\n" @@ -1695,7 +1695,7 @@ msgid "" ">>> screen.reset()\n" msgstr "" -#. turtle._Screen.save +#. turtle._Screen.save (Python 3.14–3.16) msgid "" "Save the drawing as a PostScript file\n" "\n" @@ -1710,7 +1710,7 @@ msgid "" ">>> screen.save('my_drawing.eps')\n" msgstr "" -#. turtle._Screen.screensize +#. turtle._Screen.screensize (Python 3.11–3.16) msgid "" "Resize the canvas the turtles are drawing on.\n" "\n" @@ -1729,7 +1729,7 @@ msgid "" ">>> # e.g. to search for an erroneously escaped turtle ;-)\n" msgstr "" -#. turtle._Screen.setup +#. turtle._Screen.setup (Python 3.11–3.16) #, python-format msgid "" "Set the size and position of the main window.\n" @@ -1756,7 +1756,7 @@ msgid "" "sets window to 75% of screen by 50% of screen and centers\n" msgstr "" -#. turtle._Screen.setworldcoordinates +#. turtle._Screen.setworldcoordinates (Python 3.11–3.16) msgid "" "Set up a user defined coordinate-system.\n" "\n" @@ -1780,7 +1780,7 @@ msgid "" "... forward(0.5)\n" msgstr "" -#. turtle._Screen.textinput +#. turtle._Screen.textinput (Python 3.11–3.16) msgid "" "Pop up a dialog window for input of a string.\n" "\n" @@ -1795,7 +1795,7 @@ msgid "" "\n" msgstr "" -#. turtle._Screen.title +#. turtle._Screen.title (Python 3.11–3.16) msgid "" "Set title of turtle-window\n" "\n" @@ -1810,7 +1810,7 @@ msgid "" ">>> screen.title(\"Welcome to the turtle-zoo!\")\n" msgstr "" -#. turtle._Screen.tracer +#. turtle._Screen.tracer (Python 3.11–3.16) msgid "" "Turns turtle animation on/off and set delay for update drawings.\n" "\n" @@ -1831,7 +1831,7 @@ msgid "" "... dist += 2\n" msgstr "" -#. turtle._Screen.turtles +#. turtle._Screen.turtles (Python 3.11–3.16) msgid "" "Return the list of turtles on the screen.\n" "\n" @@ -1840,13 +1840,13 @@ msgid "" "[]\n" msgstr "" -#. turtle._Screen.update +#. turtle._Screen.update (Python 3.11–3.16) msgid "" "Perform a TurtleScreen update.\n" " " msgstr "" -#. turtle._Screen.window_height +#. turtle._Screen.window_height (Python 3.11–3.16) msgid "" "Return the height of the turtle window.\n" "\n" @@ -1855,7 +1855,7 @@ msgid "" "480\n" msgstr "" -#. turtle._Screen.window_width +#. turtle._Screen.window_width (Python 3.11–3.16) msgid "" "Return the width of the turtle window.\n" "\n" @@ -1864,7 +1864,7 @@ msgid "" "640\n" msgstr "" -#. turtle.write_docstringdict +#. turtle.write_docstringdict (Python 3.11–3.16) msgid "" "Create and write docstring-dictionary to file.\n" "\n" @@ -1877,3 +1877,353 @@ msgid "" "It is intended to serve as a template for translation of the docstrings\n" "into different languages.\n" msgstr "" + +#. turtle._Screen.bgpic (Python 3.11–3.13) +msgid "" +"Set background image or return name of current backgroundimage.\n" +"\n" +"Optional argument:\n" +"picname -- a string, name of a gif-file or \"nopic\".\n" +"\n" +"If picname is a filename, set the corresponding image as background.\n" +"If picname is \"nopic\", delete backgroundimage, if present.\n" +"If picname is None, return the filename of the current backgroundimage.\n" +"\n" +"Example (for a TurtleScreen instance named screen):\n" +">>> screen.bgpic()\n" +"'nopic'\n" +">>> screen.bgpic(\"landscape.gif\")\n" +">>> screen.bgpic()\n" +"'landscape.gif'\n" +msgstr "" + +#. turtle._Screen.register_shape (Python 3.11–3.13) +msgid "" +"Adds a turtle shape to TurtleScreen's shapelist.\n" +"\n" +"Arguments:\n" +"(1) name is the name of a gif-file and shape is None.\n" +" Installs the corresponding image shape.\n" +" !! Image-shapes DO NOT rotate when turning the turtle,\n" +" !! so they do not display the heading of the turtle!\n" +"(2) name is an arbitrary string and shape is a tuple\n" +" of pairs of coordinates. Installs the corresponding\n" +" polygon shape\n" +"(3) name is an arbitrary string and shape is a\n" +" (compound) Shape object. Installs the corresponding\n" +" compound shape.\n" +"To use a shape, you have to issue the command shape(shapename).\n" +"\n" +"call: register_shape(\"turtle.gif\")\n" +"--or: register_shape(\"tri\", ((0,0), (10,10), (-10,10)))\n" +"\n" +"Example (for a TurtleScreen instance named screen):\n" +">>> screen.register_shape(\"triangle\", ((5,-3),(0,5),(-5,-3)))\n" +"\n" +msgstr "" + +#. turtle.Turtle.back (Python 3.11–3.12) +msgid "" +"Move the turtle backward by distance.\n" +"\n" +"Aliases: back | backward | bk\n" +"\n" +"Argument:\n" +"distance -- a number\n" +"\n" +"Move the turtle backward by distance, opposite to the direction the\n" +"turtle is headed. Do not change the turtle's heading.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> turtle.position()\n" +"(0.00, 0.00)\n" +">>> turtle.backward(30)\n" +">>> turtle.position()\n" +"(-30.00, 0.00)\n" +msgstr "" + +#. turtle.Turtle.color (Python 3.11–3.12) +msgid "" +"Return or set the pencolor and fillcolor.\n" +"\n" +"Arguments:\n" +"Several input formats are allowed.\n" +"They use 0, 1, 2, or 3 arguments as follows:\n" +"\n" +"color()\n" +" Return the current pencolor and the current fillcolor\n" +" as a pair of color specification strings as are returned\n" +" by pencolor and fillcolor.\n" +"color(colorstring), color((r,g,b)), color(r,g,b)\n" +" inputs as in pencolor, set both, fillcolor and pencolor,\n" +" to the given value.\n" +"color(colorstring1, colorstring2),\n" +"color((r1,g1,b1), (r2,g2,b2))\n" +" equivalent to pencolor(colorstring1) and fillcolor(colorstring2)\n" +" and analogously, if the other input format is used.\n" +"\n" +"If turtleshape is a polygon, outline and interior of that polygon\n" +"is drawn with the newly set colors.\n" +"For more info see: pencolor, fillcolor\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> turtle.color('red', 'green')\n" +">>> turtle.color()\n" +"('red', 'green')\n" +">>> colormode(255)\n" +">>> color((40, 80, 120), (160, 200, 240))\n" +">>> color()\n" +"('#285078', '#a0c8f0')\n" +msgstr "" + +#. turtle.Turtle.distance (Python 3.11–3.12) +msgid "" +"Return the distance from the turtle to (x,y) in turtle step units.\n" +"\n" +"Arguments:\n" +"x -- a number or a pair/vector of numbers or a turtle instance\n" +"y -- a number None None\n" +"\n" +"call: distance(x, y) # two coordinates\n" +"--or: distance((x, y)) # a pair (tuple) of coordinates\n" +"--or: distance(vec) # e.g. as returned by pos()\n" +"--or: distance(mypen) # where mypen is another turtle\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> turtle.pos()\n" +"(0.00, 0.00)\n" +">>> turtle.distance(30,40)\n" +"50.0\n" +">>> pen = Turtle()\n" +">>> pen.forward(77)\n" +">>> turtle.distance(pen)\n" +"77.0\n" +msgstr "" + +#. turtle.Turtle.fillcolor (Python 3.11–3.12) +msgid "" +"Return or set the fillcolor.\n" +"\n" +"Arguments:\n" +"Four input formats are allowed:\n" +" - fillcolor()\n" +" Return the current fillcolor as color specification string,\n" +" possibly in hex-number format (see example).\n" +" May be used as input to another color/pencolor/fillcolor call.\n" +" - fillcolor(colorstring)\n" +" s is a Tk color specification string, such as \"red\" or \"yellow\"\n" +" - fillcolor((r, g, b))\n" +" *a tuple* of r, g, and b, which represent, an RGB color,\n" +" and each of r, g, and b are in the range 0..colormode,\n" +" where colormode is either 1.0 or 255\n" +" - fillcolor(r, g, b)\n" +" r, g, and b represent an RGB color, and each of r, g, and b\n" +" are in the range 0..colormode\n" +"\n" +"If turtleshape is a polygon, the interior of that polygon is drawn\n" +"with the newly set fillcolor.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> turtle.fillcolor('violet')\n" +">>> col = turtle.pencolor()\n" +">>> turtle.fillcolor(col)\n" +">>> turtle.fillcolor(0, .5, 0)\n" +msgstr "" + +#. turtle.Turtle.forward (Python 3.11–3.12) +msgid "" +"Move the turtle forward by the specified distance.\n" +"\n" +"Aliases: forward | fd\n" +"\n" +"Argument:\n" +"distance -- a number (integer or float)\n" +"\n" +"Move the turtle forward by the specified distance, in the direction\n" +"the turtle is headed.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> turtle.position()\n" +"(0.00, 0.00)\n" +">>> turtle.forward(25)\n" +">>> turtle.position()\n" +"(25.00,0.00)\n" +">>> turtle.forward(-75)\n" +">>> turtle.position()\n" +"(-50.00,0.00)\n" +msgstr "" + +#. turtle.Turtle.goto (Python 3.11–3.12) +msgid "" +"Move turtle to an absolute position.\n" +"\n" +"Aliases: setpos | setposition | goto:\n" +"\n" +"Arguments:\n" +"x -- a number or a pair/vector of numbers\n" +"y -- a number None\n" +"\n" +"call: goto(x, y) # two coordinates\n" +"--or: goto((x, y)) # a pair (tuple) of coordinates\n" +"--or: goto(vec) # e.g. as returned by pos()\n" +"\n" +"Move turtle to an absolute position. If the pen is down,\n" +"a line will be drawn. The turtle's orientation does not change.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> tp = turtle.pos()\n" +">>> tp\n" +"(0.00, 0.00)\n" +">>> turtle.setpos(60,30)\n" +">>> turtle.pos()\n" +"(60.00,30.00)\n" +">>> turtle.setpos((20,80))\n" +">>> turtle.pos()\n" +"(20.00,80.00)\n" +">>> turtle.setpos(tp)\n" +">>> turtle.pos()\n" +"(0.00,0.00)\n" +msgstr "" + +#. turtle.Turtle.pencolor (Python 3.11–3.12) +msgid "" +"Return or set the pencolor.\n" +"\n" +"Arguments:\n" +"Four input formats are allowed:\n" +" - pencolor()\n" +" Return the current pencolor as color specification string,\n" +" possibly in hex-number format (see example).\n" +" May be used as input to another color/pencolor/fillcolor call.\n" +" - pencolor(colorstring)\n" +" s is a Tk color specification string, such as \"red\" or \"yellow\"\n" +" - pencolor((r, g, b))\n" +" *a tuple* of r, g, and b, which represent, an RGB color,\n" +" and each of r, g, and b are in the range 0..colormode,\n" +" where colormode is either 1.0 or 255\n" +" - pencolor(r, g, b)\n" +" r, g, and b represent an RGB color, and each of r, g, and b\n" +" are in the range 0..colormode\n" +"\n" +"If turtleshape is a polygon, the outline of that polygon is drawn\n" +"with the newly set pencolor.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> turtle.pencolor('brown')\n" +">>> tup = (0.2, 0.8, 0.55)\n" +">>> turtle.pencolor(tup)\n" +">>> turtle.pencolor()\n" +"'#33cc8c'\n" +msgstr "" + +#. turtle.Turtle.settiltangle (Python 3.11–3.12) +msgid "" +"Rotate the turtleshape to point in the specified direction\n" +"\n" +"Argument: angle -- number\n" +"\n" +"Rotate the turtleshape to point in the direction specified by angle,\n" +"regardless of its current tilt-angle. DO NOT change the turtle's\n" +"heading (direction of movement).\n" +"\n" +"Deprecated since Python 3.1\n" +"\n" +"Examples (for a Turtle instance named turtle):\n" +">>> turtle.shape(\"circle\")\n" +">>> turtle.shapesize(5,2)\n" +">>> turtle.settiltangle(45)\n" +">>> turtle.stamp()\n" +">>> turtle.fd(50)\n" +">>> turtle.settiltangle(-45)\n" +">>> turtle.stamp()\n" +">>> turtle.fd(50)\n" +msgstr "" + +#. turtle.Turtle.tiltangle (Python 3.11–3.12) +msgid "" +"Set or return the current tilt-angle.\n" +"\n" +"Optional argument: angle -- number\n" +"\n" +"Rotate the turtleshape to point in the direction specified by angle,\n" +"regardless of its current tilt-angle. DO NOT change the turtle's\n" +"heading (direction of movement).\n" +"If angle is not given: return the current tilt-angle, i. e. the angle\n" +"between the orientation of the turtleshape and the heading of the\n" +"turtle (its direction of movement).\n" +"\n" +"(Incorrectly marked as deprecated since Python 3.1, it is really\n" +"settiltangle that is deprecated.)\n" +"\n" +"Examples (for a Turtle instance named turtle):\n" +">>> turtle.shape(\"circle\")\n" +">>> turtle.shapesize(5, 2)\n" +">>> turtle.tiltangle()\n" +"0.0\n" +">>> turtle.tiltangle(45)\n" +">>> turtle.tiltangle()\n" +"45.0\n" +">>> turtle.stamp()\n" +">>> turtle.fd(50)\n" +">>> turtle.tiltangle(-45)\n" +">>> turtle.tiltangle()\n" +"315.0\n" +">>> turtle.stamp()\n" +">>> turtle.fd(50)\n" +msgstr "" + +#. turtle._Screen.bgcolor (Python 3.11–3.12) +msgid "" +"Set or return backgroundcolor of the TurtleScreen.\n" +"\n" +"Arguments (if given): a color string or three numbers\n" +"in the range 0..colormode or a 3-tuple of such numbers.\n" +"\n" +"Example (for a TurtleScreen instance named screen):\n" +">>> screen.bgcolor(\"orange\")\n" +">>> screen.bgcolor()\n" +"'orange'\n" +">>> screen.bgcolor(0.5,0,0.5)\n" +">>> screen.bgcolor()\n" +"'#800080'\n" +msgstr "" + +#. turtle.Turtle.isvisible (Python 3.11) +msgid "" +"Return True if the Turtle is shown, False if it's hidden.\n" +"\n" +"No argument.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> turtle.hideturtle()\n" +">>> print turtle.isvisible():\n" +"False\n" +msgstr "" + +#. turtle.Turtle.xcor (Python 3.11) +msgid "" +"Return the turtle's x coordinate.\n" +"\n" +"No arguments.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> reset()\n" +">>> turtle.left(60)\n" +">>> turtle.forward(100)\n" +">>> print turtle.xcor()\n" +"50.0\n" +msgstr "" + +#. turtle.Turtle.ycor (Python 3.11) +msgid "" +"Return the turtle's y coordinate\n" +"---\n" +"No arguments.\n" +"\n" +"Example (for a Turtle instance named turtle):\n" +">>> reset()\n" +">>> turtle.left(60)\n" +">>> turtle.forward(100)\n" +">>> print turtle.ycor()\n" +"86.6025403784\n" +msgstr "" diff --git a/pyproject.toml b/pyproject.toml index 3305f52..cb7e21e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,15 +9,19 @@ description = "Docstring translations for the Python turtle module" readme = "README.md" license = "PSF-2.0" authors = [ { name = "Stan Ulbrych", email = "stan@python.org" } ] -requires-python = ">=3.13" +requires-python = ">=3.11" classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Education", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", + "Programming Language :: Python :: 3.16", "Topic :: Education", "Topic :: Software Development :: Localization", ] @@ -26,3 +30,21 @@ urls.Source = "https://github.com/python/turtle-translations" [tool.hatch] build.targets.wheel.hooks.custom.path = "scripts/hook.py" +build.targets.wheel.only-include = [ "turtle_translations/__init__.py" ] +build.targets.sdist.include = [ + "/LICENSE", + "/po/*.po", + "/pyproject.toml", + "/README.md", + "/scripts/*.py", + "/sources", + "/tests", + "/turtle_translations/__init__.py", +] + +[tool.check-wheel-contents] +# turtle imports the root shim; version-specific dictionaries live in the package. +toplevel = [ "turtle_docstringdict_pl.py", "turtle_translations" ] + +[tool.pyproject-fmt] +max_supported_python = "3.16" diff --git a/scripts/hook.py b/scripts/hook.py index 47963c8..8f7c53e 100644 --- a/scripts/hook.py +++ b/scripts/hook.py @@ -1,6 +1,7 @@ """Hatchling build hook to compile the PO catalogs when the wheel is built.""" import sys +import tempfile from pathlib import Path from hatchling.builders.hooks.plugin.interface import BuildHookInterface @@ -11,7 +12,10 @@ class CustomBuildHook(BuildHookInterface): def initialize(self, version, build_data): - # The generated modules are gitignored, so hatch need to be told to ship them. - build_data["artifacts"] = [ - str(path.relative_to(self.root)) for path in i18n._compile_catalogs() - ] + self.generated = tempfile.TemporaryDirectory() + output = Path(self.generated.name) + for path in i18n._compile_catalogs(output): + build_data["force_include"][str(path)] = path.relative_to(output).as_posix() + + def finalize(self, version, build_data, artifact_path): + self.generated.cleanup() diff --git a/scripts/i18n.py b/scripts/i18n.py index c8f470d..c7b3b41 100755 --- a/scripts/i18n.py +++ b/scripts/i18n.py @@ -1,63 +1,68 @@ """Tooling for maintaining the turtle docstring catalogs.""" import argparse -import platform from datetime import datetime, timezone +from io import BytesIO +from itertools import groupby from pathlib import Path from babel.messages.catalog import Catalog from babel.messages.pofile import read_po, write_po +from sources import read_sources, refresh_sources + ROOT = Path(__file__).resolve().parent.parent PO_DIR = ROOT / "po" -PACKAGE_DIR = ROOT / "turtle_translations" POT = PO_DIR / "turtle.pot" PROJECT = "turtle-translations" BUGS_ADDRESS = "https://github.com/python/turtle-translations/issues" - -def _extract_docstrings(): - # XXX: turtle.write_docstringdict() only extracts a subset of docstrings and - # appends a newline to every docstring. - import turtle - - skip = set(turtle._alias_list) | {"Pen", "RawPen", "done"} - result = {} - for name in turtle.__all__: - if name in skip: - continue - if name in turtle._tg_screen_functions: - key = f"_Screen.{name}" - elif name in turtle._tg_turtle_functions: - key = f"Turtle.{name}" - else: - key = name - result[key] = eval(key, vars(turtle)).__doc__ - return dict(sorted(result.items())) +def _version_ranges(versions): + versions = sorted(tuple(map(int, version.split("."))) for version in versions) + ranges = [] + for _, group in groupby(enumerate(versions), + key=lambda item: (item[1][0], item[1][1] - item[0])): + members = [version for _, version in group] + first, last = (".".join(map(str, version)) for version in (members[0], members[-1])) + ranges.append(first if first == last else f"{first}–{last}") + return ", ".join(ranges) -def build_template(): +def build_template(data=None): + if data is None: + data = read_sources() + versions = sorted(data["versions"], key=lambda version: tuple(map(int, version.split(".")))) catalog = Catalog( project=PROJECT, - version=platform.python_version(), + version=f"{versions[0]}–{versions[-1]}", msgid_bugs_address=BUGS_ADDRESS, charset="utf-8", header_comment=( "# Docstrings of the Python turtle module.\n" - f"# Extracted from Python {platform.python_version()}.\n" + f"# Extracted from Python {versions[0]}–{versions[-1]}.\n" "# This file was generated via 'scripts/i18n.py extract'." ), ) - for key, doc in _extract_docstrings().items(): - catalog.add(doc, auto_comments=[f"turtle.{key}"]) + uses = {} + for version in reversed(versions): + info = data["versions"][version] + for key, doc in data["groups"][info["group"]].items(): + uses.setdefault(doc, {}).setdefault(key, []).append(version) + for doc, methods in uses.items(): + catalog.add(doc, auto_comments=[ + f"turtle.{key} (Python {_version_ranges(versions)})" + for key, versions in methods.items() + ]) return catalog def write_catalog(catalog, path, **kwargs): path.parent.mkdir(parents=True, exist_ok=True) - with path.open("wb") as f: - write_po(f, catalog, width=None, **kwargs) + buffer = BytesIO() + write_po(buffer, catalog, width=None, **kwargs) + # avoid double newline at the end of file + path.write_bytes(buffer.getvalue().rstrip() + b"\n") def read_catalog(path, **kwargs): @@ -66,10 +71,11 @@ def read_catalog(path, **kwargs): def cmd_extract(args): - catalog = build_template() + data = refresh_sources(args.cpython) if args.cpython else read_sources() + catalog = build_template(data) write_catalog(catalog, POT) - print(f"{POT.relative_to(ROOT)}: {len(catalog)} docstrings " - f"from Python {platform.python_version()}") + print(f"{POT.relative_to(ROOT)}: {len(catalog)} distinct docstrings " + f"from Python {catalog.version}") def po_files(langs=None): @@ -105,27 +111,69 @@ def cmd_update(args): print(f"Updated: {path.relative_to(ROOT)}") -def _load_docsdict(path): +def _load_docsdict(path, docs): catalog = read_catalog(path) - return { - comment.removeprefix("turtle."): message.string - for message in catalog - if message.id and message.string and not message.fuzzy - for comment in message.auto_comments - } - - -def _compile_catalogs(): + result = {} + for key, original in docs.items(): + message = catalog.get(original) + if message is not None and message.string and not message.fuzzy: + result[key] = message.string + return result + + +def _module_name(lang, group): + return f"{lang}.py{group.replace('.', '')}" + + +def _render_shim(lang, data): + transitions = [] + previous = None + for version, info in data["versions"].items(): + group = info["group"] + if group != previous: + transitions.append((tuple(map(int, version.split("."))), group)) + previous = group + lines = ["# Generated by scripts/i18n.py. Do not edit.", "", "import sys", ""] + for index, (version, group) in enumerate(reversed(transitions[1:])): + keyword = "if" if index == 0 else "elif" + lines.extend([ + f"{keyword} sys.version_info[:2] >= {version!r}:", + f" from turtle_translations.{_module_name(lang, group)} import docsdict as docsdict", + ]) + fallback = f"from turtle_translations.{_module_name(lang, transitions[0][1])} import docsdict as docsdict" + if len(transitions) > 1: + lines.extend(["else:", f" {fallback}"]) + else: + lines.append(fallback) + return "\n".join(lines) + "\n" + + +def _compile_catalogs(output_dir=None): + output_dir = ROOT if output_dir is None else Path(output_dir) + package_dir = output_dir / "turtle_translations" + package_dir.mkdir(parents=True, exist_ok=True) + data = read_sources() written = [] for path in po_files(): # turtle lowercases the language before importing it! - target = PACKAGE_DIR / f"{path.stem.lower()}.py" - lines = [f"# Generated from {path.name}.", "", "docsdict = {"] - for key, doc in sorted(_load_docsdict(path).items()): - lines.append(f" {key!r}: {doc!r},") - lines.append("}") - target.write_text("\n".join(lines) + "\n", encoding="utf-8") - written.append(target) + lang = path.stem.lower() + for group, docs in data["groups"].items(): + target = package_dir / lang / f"py{group.replace('.', '')}.py" + target.parent.mkdir(parents=True, exist_ok=True) + lines = [f"# Generated from {path.name} for Python {group}.", "", "docsdict = {"] + for key, doc in sorted(_load_docsdict(path, docs).items()): + lines.append(f" {key!r}: {doc!r},") + lines.append("}") + target.write_text("\n".join(lines) + "\n", encoding="utf-8") + written.append(target) + package_init = package_dir / lang / "__init__.py" + package_init.write_text( + f"# Generated package for {path.name}.\n", encoding="utf-8" + ) + written.append(package_init) + shim = output_dir / f"turtle_docstringdict_{lang}.py" + shim.write_text(_render_shim(lang, data), encoding="utf-8") + written.append(shim) return written @@ -160,7 +208,10 @@ def main(argv=None): parser = argparse.ArgumentParser(description=__doc__) sub = parser.add_subparsers(dest="command", required=True) - sub.add_parser("extract", help="write `po/turtle.pot`").set_defaults(func=cmd_extract) + p = sub.add_parser("extract", help="write the union template `po/turtle.pot`") + p.add_argument("--cpython", type=Path, + help="refresh source mappings from a CPython checkout's upstream refs") + p.set_defaults(func=cmd_extract) p = sub.add_parser("init", help="create a PO file for a new language") p.add_argument("lang", help="language code, e.g. `pl`") diff --git a/scripts/sources.py b/scripts/sources.py new file mode 100644 index 0000000..60daede --- /dev/null +++ b/scripts/sources.py @@ -0,0 +1,155 @@ +"""Extract versioned English turtle docstrings without importing turtle.""" + +import ast +import json +import subprocess +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +SOURCES = ROOT / "sources" / "turtle.json" +REPORT = ROOT / "sources" / "README.md" +REFS = {f"3.{minor}": f"upstream/{'main' if minor == 16 else f'3.{minor}'}" + for minor in range(11, 17)} + + +def normalize_docstring(doc): + """Match CPython's indentation cleanup, retaining leading/trailing blank lines.""" + lines = doc.expandtabs().split("\n") + margin = min((len(line) - len(line.lstrip(" ")) for line in lines[1:] + if line.strip(" ")), default=0) + return "\n".join([lines[0].lstrip(" ")] + + [line[min(margin, len(line) - len(line.lstrip(" "))):] + for line in lines[1:]]) + + +def extract_docstrings(source): + """Resolve public names, inherited methods, and simple method aliases.""" + tree = ast.parse(source) + classes = {node.name: node for node in tree.body if isinstance(node, ast.ClassDef)} + objects = {node.name: ast.get_docstring(node, clean=False) + for node in tree.body + if isinstance(node, (ast.ClassDef, ast.FunctionDef))} + values = {} + + def literal(node): + if isinstance(node, ast.Name): + return values[node.id] + if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Add): + return literal(node.left) + literal(node.right) + return ast.literal_eval(node) + + for node in tree.body: + if isinstance(node, ast.Assign): + try: + value = literal(node.value) + except (ValueError, KeyError, TypeError): + continue + for target in node.targets: + if isinstance(target, ast.Name): + values[target.id] = value + + def methods(name): + result = {} + # Earlier bases take precedence in turtle's simple inheritance trees. + for base in reversed(classes[name].bases): + if isinstance(base, ast.Name) and base.id in classes: + result.update(methods(base.id)) + for node in classes[name].body: + if isinstance(node, ast.FunctionDef): + result[node.name] = ast.get_docstring(node, clean=False) + elif isinstance(node, ast.Assign) and isinstance(node.value, ast.Name): + if node.value.id in result: + for target in node.targets: + if isinstance(target, ast.Name): + result[target.id] = result[node.value.id] + return result + + screen = methods("_Screen") + turtle = methods("Turtle") + skip = set(values["_alias_list"]) | {"Pen", "RawPen", "done"} + result = {} + for name in values["__all__"]: + if name in skip: + continue + if name in values["_tg_screen_functions"]: + key, doc = f"_Screen.{name}", screen[name] + elif name in values["_tg_turtle_functions"]: + key, doc = f"Turtle.{name}", turtle[name] + else: + key, doc = name, objects[name] + if doc: + result[key] = normalize_docstring(doc) + return dict(sorted(result.items())) + + +def read_sources(path=SOURCES): + return json.loads(path.read_text(encoding="utf-8")) + + +def collect_sources(checkout): + def git(*args): + return subprocess.check_output( + ["git", "-C", str(checkout), *args], text=True, encoding="utf-8" + ) + + groups = {} + versions = {} + for version, ref in REFS.items(): + commit = git("rev-parse", ref).strip() + docs = extract_docstrings(git("show", f"{commit}:Lib/turtle.py")) + group = next((key for key, value in groups.items() if value == docs), version) + groups[group] = docs + versions[version] = {"ref": ref, "commit": commit, "group": group} + return {"versions": versions, "groups": groups} + + +def render_report(data): + lines = [ + "# Turtle docstring compatibility", "", + "Generated by `python scripts/i18n.py extract --cpython ../cpython`.", "", + "These are local upstream branch snapshots, not a comparison of every patch release.", + "Python 3.16 uses `upstream/main`. Counts refer to public names with docstrings,", + "excluding aliases, following the catalog extractor's scope.", "", + "Source indentation is normalized using CPython's docstring cleanup convention;", + "leading and trailing blank lines are preserved. This avoids translation variants", + "caused solely by compiler indentation cleanup in newer Python versions.", "", + "| Python | Ref | Commit | Names | Dictionary group |", + "| --- | --- | --- | ---: | --- |", + ] + for version, info in data["versions"].items(): + docs = data["groups"][info["group"]] + lines.append(f"| {version} | `{info['ref']}` | `{info['commit']}` | " + f"{len(docs)} | {info['group']} |") + previous = None + for version, info in data["versions"].items(): + docs = data["groups"][info["group"]] + lines.extend(["", f"## Python {version}", ""]) + if previous is None: + lines.append("Baseline.") + else: + changes = { + "Added": sorted(docs.keys() - previous.keys()), + "Removed": sorted(previous.keys() - docs.keys()), + "Changed": sorted(key for key in docs.keys() & previous.keys() + if docs[key] != previous[key]), + } + if not any(changes.values()): + lines.append("No docstring changes from the preceding version.") + for label, keys in changes.items(): + if keys: + lines.append(f"- {label}: " + ", ".join(f"`{key}`" for key in keys) + ".") + previous = docs + lines.extend(["", "## Updating", "", + "`turtle.json` records exact English text and source provenance. Equal snapshots", + "share a dictionary group. Extraction regenerates the union template; run", + "`python scripts/i18n.py update` afterwards to merge it into the language catalogs.", + "Builds use the committed mappings and do not need a CPython checkout.", ""]) + return "\n".join(lines) + + +def refresh_sources(checkout): + data = collect_sources(checkout) + SOURCES.parent.mkdir(parents=True, exist_ok=True) + SOURCES.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + REPORT.write_text(render_report(data), encoding="utf-8") + return data diff --git a/sources/NOTICE b/sources/NOTICE new file mode 100644 index 0000000..1d6d5a3 --- /dev/null +++ b/sources/NOTICE @@ -0,0 +1,25 @@ +The English docstrings in turtle.json are extracted from CPython Lib/turtle.py. +The extracted data is an altered, partial representation of that module. + +# +# turtle.py: a Tkinter based turtle graphics module for Python +# Version 1.1b - 4. 5. 2009 +# +# Copyright (C) 2006 - 2010 Gregor Lingl +# email: glingl@aon.at +# +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the authors be held liable for any damages +# arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not +# claim that you wrote the original software. If you use this software +# in a product, an acknowledgment in the product documentation would be +# appreciated but is not required. +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# 3. This notice may not be removed or altered from any source distribution. diff --git a/sources/README.md b/sources/README.md new file mode 100644 index 0000000..6866a9e --- /dev/null +++ b/sources/README.md @@ -0,0 +1,54 @@ +# Turtle docstring compatibility + +Generated by `python scripts/i18n.py extract --cpython ../cpython`. + +These are local upstream branch snapshots, not a comparison of every patch release. +Python 3.16 uses `upstream/main`. Counts refer to public names with docstrings, +excluding aliases, following the catalog extractor's scope. + +Source indentation is normalized using CPython's docstring cleanup convention; +leading and trailing blank lines are preserved. This avoids translation variants +caused solely by compiler indentation cleanup in newer Python versions. + +| Python | Ref | Commit | Names | Dictionary group | +| --- | --- | --- | ---: | --- | +| 3.11 | `upstream/3.11` | `9eaf48a56547872b86de5cecbaa7edd3279159ed` | 102 | 3.11 | +| 3.12 | `upstream/3.12` | `c016c2535b74227fddf2cf7334dbfead6c930214` | 103 | 3.12 | +| 3.13 | `upstream/3.13` | `02d44063960107556b73248b195bb4886ff42b59` | 102 | 3.13 | +| 3.14 | `upstream/3.14` | `484e025049d43c400d27097d969d3971076eff12` | 106 | 3.14 | +| 3.15 | `upstream/3.15` | `3654c0d12f71b432a287ddf93b9494c170029c6f` | 106 | 3.14 | +| 3.16 | `upstream/main` | `e9ae46f02b073d52f277152f5e22128525a9e3f7` | 106 | 3.14 | + +## Python 3.11 + +Baseline. + +## Python 3.12 + +- Added: `Turtle.teleport`. +- Changed: `Turtle.isvisible`, `Turtle.xcor`, `Turtle.ycor`. + +## Python 3.13 + +- Removed: `Turtle.settiltangle`. +- Changed: `Turtle.back`, `Turtle.color`, `Turtle.distance`, `Turtle.fillcolor`, `Turtle.forward`, `Turtle.goto`, `Turtle.pencolor`, `Turtle.tiltangle`, `_Screen.bgcolor`. + +## Python 3.14 + +- Added: `Turtle.fill`, `Turtle.poly`, `_Screen.no_animation`, `_Screen.save`. +- Changed: `_Screen.bgpic`, `_Screen.register_shape`. + +## Python 3.15 + +No docstring changes from the preceding version. + +## Python 3.16 + +No docstring changes from the preceding version. + +## Updating + +`turtle.json` records exact English text and source provenance. Equal snapshots +share a dictionary group. Extraction regenerates the union template; run +`python scripts/i18n.py update` afterwards to merge it into the language catalogs. +Builds use the committed mappings and do not need a CPython checkout. diff --git a/sources/turtle.json b/sources/turtle.json new file mode 100644 index 0000000..01b61eb --- /dev/null +++ b/sources/turtle.json @@ -0,0 +1,457 @@ +{ + "versions": { + "3.11": { + "ref": "upstream/3.11", + "commit": "9eaf48a56547872b86de5cecbaa7edd3279159ed", + "group": "3.11" + }, + "3.12": { + "ref": "upstream/3.12", + "commit": "c016c2535b74227fddf2cf7334dbfead6c930214", + "group": "3.12" + }, + "3.13": { + "ref": "upstream/3.13", + "commit": "02d44063960107556b73248b195bb4886ff42b59", + "group": "3.13" + }, + "3.14": { + "ref": "upstream/3.14", + "commit": "484e025049d43c400d27097d969d3971076eff12", + "group": "3.14" + }, + "3.15": { + "ref": "upstream/3.15", + "commit": "3654c0d12f71b432a287ddf93b9494c170029c6f", + "group": "3.14" + }, + "3.16": { + "ref": "upstream/main", + "commit": "e9ae46f02b073d52f277152f5e22128525a9e3f7", + "group": "3.14" + } + }, + "groups": { + "3.11": { + "RawTurtle": "Animation part of the RawTurtle.\nPuts RawTurtle upon a TurtleScreen and provides tools for\nits animation.\n", + "Screen": "Return the singleton screen object.\nIf none exists at the moment, create a new one and return it,\nelse return the existing one.", + "ScrolledCanvas": "Modeled after the scrolled canvas class from Grayons's Tkinter book.\n\nUsed as the default canvas, which pops up automatically when\nusing turtle graphics functions or the Turtle class.\n", + "Shape": "Data structure modeling shapes.\n\nattribute _type is one of \"polygon\", \"image\", \"compound\"\nattribute _data is - depending on _type a poygon-tuple,\nan image or a list constructed using the addcomponent method.\n", + "Terminator": "Will be raised in TurtleScreen.update, if _RUNNING becomes False.\n\nThis stops execution of a turtle graphics script.\nMain purpose: use in the Demo-Viewer turtle.Demo.py.\n", + "Turtle": "RawTurtle auto-creating (scrolled) canvas.\n\nWhen a Turtle object is created or a function derived from some\nTurtle method is called a TurtleScreen object is automatically created.\n", + "Turtle.back": "Move the turtle backward by distance.\n\nAliases: back | backward | bk\n\nArgument:\ndistance -- a number\n\nMove the turtle backward by distance, opposite to the direction the\nturtle is headed. Do not change the turtle's heading.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 0.00)\n>>> turtle.backward(30)\n>>> turtle.position()\n(-30.00, 0.00)\n", + "Turtle.begin_fill": "Called just before drawing a shape to be filled.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.begin_poly": "Start recording the vertices of a polygon.\n\nNo argument.\n\nStart recording the vertices of a polygon. Current turtle position\nis first point of polygon.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_poly()\n", + "Turtle.circle": "Draw a circle with given radius.\n\nArguments:\nradius -- a number\nextent (optional) -- a number\nsteps (optional) -- an integer\n\nDraw a circle with given radius. The center is radius units left\nof the turtle; extent - an angle - determines which part of the\ncircle is drawn. If extent is not given, draw the entire circle.\nIf extent is not a full circle, one endpoint of the arc is the\ncurrent pen position. Draw the arc in counterclockwise direction\nif radius is positive, otherwise in clockwise direction. Finally\nthe direction of the turtle is changed by the amount of extent.\n\nAs the circle is approximated by an inscribed regular polygon,\nsteps determines the number of steps to use. If not given,\nit will be calculated automatically. Maybe used to draw regular\npolygons.\n\ncall: circle(radius) # full circle\n--or: circle(radius, extent) # arc\n--or: circle(radius, extent, steps)\n--or: circle(radius, steps=6) # 6-sided polygon\n\nExample (for a Turtle instance named turtle):\n>>> turtle.circle(50)\n>>> turtle.circle(120, 180) # semicircle\n", + "Turtle.clear": "Delete the turtle's drawings from the screen. Do not move turtle.\n\nNo arguments.\n\nDelete the turtle's drawings from the screen. Do not move turtle.\nState and position of the turtle as well as drawings of other\nturtles are not affected.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.clear()\n", + "Turtle.clearstamp": "Delete stamp with given stampid\n\nArgument:\nstampid - an integer, must be return value of previous stamp() call.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> astamp = turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.clearstamp(astamp)\n", + "Turtle.clearstamps": "Delete all or first/last n of turtle's stamps.\n\nOptional argument:\nn -- an integer\n\nIf n is None, delete all of pen's stamps,\nelse if n > 0 delete first n stamps\nelse if n < 0 delete last n stamps.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(8):\n... turtle.stamp(); turtle.fd(30)\n...\n>>> turtle.clearstamps(2)\n>>> turtle.clearstamps(-2)\n>>> turtle.clearstamps()\n", + "Turtle.clone": "Create and return a clone of the turtle.\n\nNo argument.\n\nCreate and return a clone of the turtle with same position, heading\nand turtle properties.\n\nExample (for a Turtle instance named mick):\nmick = Turtle()\njoe = mick.clone()\n", + "Turtle.color": "Return or set the pencolor and fillcolor.\n\nArguments:\nSeveral input formats are allowed.\nThey use 0, 1, 2, or 3 arguments as follows:\n\ncolor()\n Return the current pencolor and the current fillcolor\n as a pair of color specification strings as are returned\n by pencolor and fillcolor.\ncolor(colorstring), color((r,g,b)), color(r,g,b)\n inputs as in pencolor, set both, fillcolor and pencolor,\n to the given value.\ncolor(colorstring1, colorstring2),\ncolor((r1,g1,b1), (r2,g2,b2))\n equivalent to pencolor(colorstring1) and fillcolor(colorstring2)\n and analogously, if the other input format is used.\n\nIf turtleshape is a polygon, outline and interior of that polygon\nis drawn with the newly set colors.\nFor more info see: pencolor, fillcolor\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color('red', 'green')\n>>> turtle.color()\n('red', 'green')\n>>> colormode(255)\n>>> color((40, 80, 120), (160, 200, 240))\n>>> color()\n('#285078', '#a0c8f0')\n", + "Turtle.degrees": "Set angle measurement units to degrees.\n\nOptional argument:\nfullcircle - a number\n\nSet angle measurement units, i. e. set number\nof 'degrees' for a full circle. Default value is\n360 degrees.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(90)\n>>> turtle.heading()\n90\n\nChange angle measurement unit to grad (also known as gon,\ngrade, or gradian and equals 1/100-th of the right angle.)\n>>> turtle.degrees(400.0)\n>>> turtle.heading()\n100\n\n", + "Turtle.distance": "Return the distance from the turtle to (x,y) in turtle step units.\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00, 0.00)\n>>> turtle.distance(30,40)\n50.0\n>>> pen = Turtle()\n>>> pen.forward(77)\n>>> turtle.distance(pen)\n77.0\n", + "Turtle.dot": "Draw a dot with diameter size, using color.\n\nOptional arguments:\nsize -- an integer >= 1 (if given)\ncolor -- a colorstring or a numeric color tuple\n\nDraw a circular dot with diameter size, using color.\nIf size is not given, the maximum of pensize+4 and 2*pensize is used.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.dot()\n>>> turtle.fd(50); turtle.dot(20, \"blue\"); turtle.fd(50)\n", + "Turtle.down": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.end_fill": "Fill the shape drawn after the call begin_fill().\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.end_poly": "Stop recording the vertices of a polygon.\n\nNo argument.\n\nStop recording the vertices of a polygon. Current turtle position is\nlast point of polygon. This will be connected with the first point.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.end_poly()\n", + "Turtle.fillcolor": "Return or set the fillcolor.\n\nArguments:\nFour input formats are allowed:\n - fillcolor()\n Return the current fillcolor as color specification string,\n possibly in hex-number format (see example).\n May be used as input to another color/pencolor/fillcolor call.\n - fillcolor(colorstring)\n s is a Tk color specification string, such as \"red\" or \"yellow\"\n - fillcolor((r, g, b))\n *a tuple* of r, g, and b, which represent, an RGB color,\n and each of r, g, and b are in the range 0..colormode,\n where colormode is either 1.0 or 255\n - fillcolor(r, g, b)\n r, g, and b represent an RGB color, and each of r, g, and b\n are in the range 0..colormode\n\nIf turtleshape is a polygon, the interior of that polygon is drawn\nwith the newly set fillcolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.fillcolor('violet')\n>>> col = turtle.pencolor()\n>>> turtle.fillcolor(col)\n>>> turtle.fillcolor(0, .5, 0)\n", + "Turtle.filling": "Return fillstate (True if filling, False else).\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_fill()\n>>> if turtle.filling():\n... turtle.pensize(5)\n... else:\n... turtle.pensize(3)\n", + "Turtle.forward": "Move the turtle forward by the specified distance.\n\nAliases: forward | fd\n\nArgument:\ndistance -- a number (integer or float)\n\nMove the turtle forward by the specified distance, in the direction\nthe turtle is headed.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 0.00)\n>>> turtle.forward(25)\n>>> turtle.position()\n(25.00,0.00)\n>>> turtle.forward(-75)\n>>> turtle.position()\n(-50.00,0.00)\n", + "Turtle.get_poly": "Return the lastly recorded polygon.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> p = turtle.get_poly()\n>>> turtle.register_shape(\"myFavouriteShape\", p)\n", + "Turtle.get_shapepoly": "Return the current shape polygon as tuple of coordinate pairs.\n\nNo argument.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapetransform(4, -1, 0, 2)\n>>> turtle.get_shapepoly()\n((50, -20), (30, 20), (-50, 20), (-30, -20))\n\n", + "Turtle.getpen": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.getscreen": "Return the TurtleScreen object, the turtle is drawing on.\n\nNo argument.\n\nReturn the TurtleScreen object, the turtle is drawing on.\nSo TurtleScreen-methods can be called for that object.\n\nExample (for a Turtle instance named turtle):\n>>> ts = turtle.getscreen()\n>>> ts\n\n>>> ts.bgcolor(\"pink\")\n", + "Turtle.getturtle": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.goto": "Move turtle to an absolute position.\n\nAliases: setpos | setposition | goto:\n\nArguments:\nx -- a number or a pair/vector of numbers\ny -- a number None\n\ncall: goto(x, y) # two coordinates\n--or: goto((x, y)) # a pair (tuple) of coordinates\n--or: goto(vec) # e.g. as returned by pos()\n\nMove turtle to an absolute position. If the pen is down,\na line will be drawn. The turtle's orientation does not change.\n\nExample (for a Turtle instance named turtle):\n>>> tp = turtle.pos()\n>>> tp\n(0.00, 0.00)\n>>> turtle.setpos(60,30)\n>>> turtle.pos()\n(60.00,30.00)\n>>> turtle.setpos((20,80))\n>>> turtle.pos()\n(20.00,80.00)\n>>> turtle.setpos(tp)\n>>> turtle.pos()\n(0.00,0.00)\n", + "Turtle.heading": "Return the turtle's current heading.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(67)\n>>> turtle.heading()\n67.0\n", + "Turtle.hideturtle": "Makes the turtle invisible.\n\nAliases: hideturtle | ht\n\nNo argument.\n\nIt's a good idea to do this while you're in the\nmiddle of a complicated drawing, because hiding\nthe turtle speeds up the drawing observably.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n", + "Turtle.home": "Move turtle to the origin - coordinates (0,0).\n\nNo arguments.\n\nMove turtle to the origin - coordinates (0,0) and set its\nheading to its start-orientation (which depends on mode).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.home()\n", + "Turtle.isdown": "Return True if pen is down, False if it's up.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n>>> turtle.isdown()\nFalse\n>>> turtle.pendown()\n>>> turtle.isdown()\nTrue\n", + "Turtle.isvisible": "Return True if the Turtle is shown, False if it's hidden.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> print turtle.isvisible():\nFalse\n", + "Turtle.left": "Turn turtle left by angle units.\n\nAliases: left | lt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle left by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.left(45)\n>>> turtle.heading()\n67.0\n", + "Turtle.onclick": "Bind fun to mouse-click event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\nadd -- True or False. If True, new binding will be added, otherwise\n it will replace a former binding.\n\nExample for the anonymous turtle, i. e. the procedural way:\n\n>>> def turn(x, y):\n... left(360)\n...\n>>> onclick(turn) # Now clicking into the turtle will turn it.\n>>> onclick(None) # event-binding will be removed\n", + "Turtle.ondrag": "Bind fun to mouse-move event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nEvery sequence of mouse-move-events on a turtle is preceded by a\nmouse-click event on that turtle.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.ondrag(turtle.goto)\n\nSubsequently clicking and dragging a Turtle will move it\nacross the screen thereby producing handdrawings (if pen is\ndown).\n", + "Turtle.onrelease": "Bind fun to mouse-button-release event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nExample (for a MyTurtle instance named joe):\n>>> class MyTurtle(Turtle):\n... def glow(self,x,y):\n... self.fillcolor(\"red\")\n... def unglow(self,x,y):\n... self.fillcolor(\"\")\n...\n>>> joe = MyTurtle()\n>>> joe.onclick(joe.glow)\n>>> joe.onrelease(joe.unglow)\n\nClicking on joe turns fillcolor red, unclicking turns it to\ntransparent.\n", + "Turtle.pen": "Return or set the pen's attributes.\n\nArguments:\n pen -- a dictionary with some or all of the below listed keys.\n **pendict -- one or more keyword-arguments with the below\n listed keys as keywords.\n\nReturn or set the pen's attributes in a 'pen-dictionary'\nwith the following key/value pairs:\n \"shown\" : True/False\n \"pendown\" : True/False\n \"pencolor\" : color-string or color-tuple\n \"fillcolor\" : color-string or color-tuple\n \"pensize\" : positive number\n \"speed\" : number in range 0..10\n \"resizemode\" : \"auto\" or \"user\" or \"noresize\"\n \"stretchfactor\": (positive number, positive number)\n \"shearfactor\": number\n \"outline\" : positive number\n \"tilt\" : number\n\nThis dictionary can be used as argument for a subsequent\npen()-call to restore the former pen-state. Moreover one\nor more of these attributes can be provided as keyword-arguments.\nThis can be used to set several pen attributes in one statement.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.pen(fillcolor=\"black\", pencolor=\"red\", pensize=10)\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> penstate=turtle.pen()\n>>> turtle.color(\"yellow\",\"\")\n>>> turtle.penup()\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> p.pen(penstate, fillcolor=\"green\")\n>>> p.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n", + "Turtle.pencolor": "Return or set the pencolor.\n\nArguments:\nFour input formats are allowed:\n - pencolor()\n Return the current pencolor as color specification string,\n possibly in hex-number format (see example).\n May be used as input to another color/pencolor/fillcolor call.\n - pencolor(colorstring)\n s is a Tk color specification string, such as \"red\" or \"yellow\"\n - pencolor((r, g, b))\n *a tuple* of r, g, and b, which represent, an RGB color,\n and each of r, g, and b are in the range 0..colormode,\n where colormode is either 1.0 or 255\n - pencolor(r, g, b)\n r, g, and b represent an RGB color, and each of r, g, and b\n are in the range 0..colormode\n\nIf turtleshape is a polygon, the outline of that polygon is drawn\nwith the newly set pencolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pencolor('brown')\n>>> tup = (0.2, 0.8, 0.55)\n>>> turtle.pencolor(tup)\n>>> turtle.pencolor()\n'#33cc8c'\n", + "Turtle.pendown": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.pensize": "Set or return the line thickness.\n\nAliases: pensize | width\n\nArgument:\nwidth -- positive number\n\nSet the line thickness to width or return it. If resizemode is set\nto \"auto\" and turtleshape is a polygon, that polygon is drawn with\nthe same line thickness. If no argument is given, current pensize\nis returned.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pensize()\n1\n>>> turtle.pensize(10) # from here on lines of width 10 are drawn\n", + "Turtle.penup": "Pull the pen up -- no drawing when moving.\n\nAliases: penup | pu | up\n\nNo argument\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n", + "Turtle.position": "Return the turtle's current location (x,y), as a Vec2D-vector.\n\nAliases: pos | position\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00, 240.00)\n", + "Turtle.radians": "Set the angle measurement units to radians.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n90\n>>> turtle.radians()\n>>> turtle.heading()\n1.5707963267948966\n", + "Turtle.reset": "Delete the turtle's drawings and restore its default values.\n\nNo argument.\n\nDelete the turtle's drawings from the screen, re-center the turtle\nand set variables to the default values.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,-22.00)\n>>> turtle.heading()\n100.0\n>>> turtle.reset()\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.heading()\n0.0\n", + "Turtle.resizemode": "Set resizemode to one of the values: \"auto\", \"user\", \"noresize\".\n\n(Optional) Argument:\nrmode -- one of the strings \"auto\", \"user\", \"noresize\"\n\nDifferent resizemodes have the following effects:\n - \"auto\" adapts the appearance of the turtle\n corresponding to the value of pensize.\n - \"user\" adapts the appearance of the turtle according to the\n values of stretchfactor and outlinewidth (outline),\n which are set by shapesize()\n - \"noresize\" no adaption of the turtle's appearance takes place.\nIf no argument is given, return current resizemode.\nresizemode(\"user\") is called by a call of shapesize with arguments.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"noresize\")\n>>> turtle.resizemode()\n'noresize'\n", + "Turtle.right": "Turn turtle right by angle units.\n\nAliases: right | rt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle right by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.right(45)\n>>> turtle.heading()\n337.0\n", + "Turtle.setheading": "Set the orientation of the turtle to to_angle.\n\nAliases: setheading | seth\n\nArgument:\nto_angle -- a number (integer or float)\n\nSet the orientation of the turtle to to_angle.\nHere are some common directions in degrees:\n\n standard - mode: logo-mode:\n-------------------|--------------------\n 0 - east 0 - north\n 90 - north 90 - east\n 180 - west 180 - south\n 270 - south 270 - west\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setheading(90)\n>>> turtle.heading()\n90\n", + "Turtle.settiltangle": "Rotate the turtleshape to point in the specified direction\n\nArgument: angle -- number\n\nRotate the turtleshape to point in the direction specified by angle,\nregardless of its current tilt-angle. DO NOT change the turtle's\nheading (direction of movement).\n\nDeprecated since Python 3.1\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.settiltangle(45)\n>>> turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.settiltangle(-45)\n>>> turtle.stamp()\n>>> turtle.fd(50)\n", + "Turtle.setundobuffer": "Set or disable undobuffer.\n\nArgument:\nsize -- an integer or None\n\nIf size is an integer an empty undobuffer of given size is installed.\nSize gives the maximum number of turtle-actions that can be undone\nby the undo() function.\nIf size is None, no undobuffer is present.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setundobuffer(42)\n", + "Turtle.setx": "Set the turtle's first coordinate to x\n\nArgument:\nx -- a number (integer or float)\n\nSet the turtle's first coordinate to x, leave second coordinate\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 240.00)\n>>> turtle.setx(10)\n>>> turtle.position()\n(10.00, 240.00)\n", + "Turtle.sety": "Set the turtle's second coordinate to y\n\nArgument:\ny -- a number (integer or float)\n\nSet the turtle's first coordinate to x, second coordinate remains\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 40.00)\n>>> turtle.sety(-10)\n>>> turtle.position()\n(0.00, -10.00)\n", + "Turtle.shape": "Set turtle shape to shape with given name / return current shapename.\n\nOptional argument:\nname -- a string, which is a valid shapename\n\nSet turtle shape to shape with given name or, if name is not given,\nreturn name of current shape.\nShape with name must exist in the TurtleScreen's shape dictionary.\nInitially there are the following polygon shapes:\n'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'.\nTo learn about how to deal with shapes see Screen-method register_shape.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.shape()\n'arrow'\n>>> turtle.shape(\"turtle\")\n>>> turtle.shape()\n'turtle'\n", + "Turtle.shapesize": "Set/return turtle's stretchfactors/outline. Set resizemode to \"user\".\n\nOptional arguments:\n stretch_wid : positive number\n stretch_len : positive number\n outline : positive number\n\nReturn or set the pen's attributes x/y-stretchfactors and/or outline.\nSet resizemode to \"user\".\nIf and only if resizemode is set to \"user\", the turtle will be displayed\nstretched according to its stretchfactors:\nstretch_wid is stretchfactor perpendicular to orientation\nstretch_len is stretchfactor in direction of turtles orientation.\noutline determines the width of the shapes's outline.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"user\")\n>>> turtle.shapesize(5, 5, 12)\n>>> turtle.shapesize(outline=8)\n", + "Turtle.shapetransform": "Set or return the current transformation matrix of the turtle shape.\n\nOptional arguments: t11, t12, t21, t22 -- numbers.\n\nIf none of the matrix elements are given, return the transformation\nmatrix.\nOtherwise set the given elements and transform the turtleshape\naccording to the matrix consisting of first row t11, t12 and\nsecond row t21, 22.\nModify stretchfactor, shearfactor and tiltangle according to the\ngiven matrix.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapesize(4,2)\n>>> turtle.shearfactor(-0.5)\n>>> turtle.shapetransform()\n(4.0, -1.0, -0.0, 2.0)\n", + "Turtle.shearfactor": "Set or return the current shearfactor.\n\nOptional argument: shear -- number, tangent of the shear angle\n\nShear the turtleshape according to the given shearfactor shear,\nwhich is the tangent of the shear angle. DO NOT change the\nturtle's heading (direction of movement).\nIf shear is not given: return the current shearfactor, i. e. the\ntangent of the shear angle, by which lines parallel to the\nheading of the turtle are sheared.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.shearfactor(0.5)\n>>> turtle.shearfactor()\n>>> 0.5\n", + "Turtle.showturtle": "Makes the turtle visible.\n\nAliases: showturtle | st\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> turtle.showturtle()\n", + "Turtle.speed": "Return or set the turtle's speed.\n\nOptional argument:\nspeed -- an integer in the range 0..10 or a speedstring (see below)\n\nSet the turtle's speed to an integer value in the range 0 .. 10.\nIf no argument is given: return current speed.\n\nIf input is a number greater than 10 or smaller than 0.5,\nspeed is set to 0.\nSpeedstrings are mapped to speedvalues in the following way:\n 'fastest' : 0\n 'fast' : 10\n 'normal' : 6\n 'slow' : 3\n 'slowest' : 1\nspeeds from 1 to 10 enforce increasingly faster animation of\nline drawing and turtle turning.\n\nAttention:\nspeed = 0 : *no* animation takes place. forward/back makes turtle jump\nand likewise left/right make the turtle turn instantly.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.speed(3)\n", + "Turtle.stamp": "Stamp a copy of the turtleshape onto the canvas and return its id.\n\nNo argument.\n\nStamp a copy of the turtle shape onto the canvas at the current\nturtle position. Return a stamp_id for that stamp, which can be\nused to delete it by calling clearstamp(stamp_id).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> turtle.stamp()\n13\n>>> turtle.fd(50)\n", + "Turtle.tilt": "Rotate the turtleshape by angle.\n\nArgument:\nangle - a number\n\nRotate the turtleshape by angle from its current tilt-angle,\nbut do NOT change the turtle's heading (direction of movement).\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n", + "Turtle.tiltangle": "Set or return the current tilt-angle.\n\nOptional argument: angle -- number\n\nRotate the turtleshape to point in the direction specified by angle,\nregardless of its current tilt-angle. DO NOT change the turtle's\nheading (direction of movement).\nIf angle is not given: return the current tilt-angle, i. e. the angle\nbetween the orientation of the turtleshape and the heading of the\nturtle (its direction of movement).\n\n(Incorrectly marked as deprecated since Python 3.1, it is really\nsettiltangle that is deprecated.)\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5, 2)\n>>> turtle.tiltangle()\n0.0\n>>> turtle.tiltangle(45)\n>>> turtle.tiltangle()\n45.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.tiltangle(-45)\n>>> turtle.tiltangle()\n315.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n", + "Turtle.towards": "Return the angle of the line from the turtle's position to (x, y).\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nReturn the angle, between the line from turtle-position to position\nspecified by x, y and the turtle's start orientation. (Depends on\nmodes - \"standard\" or \"logo\")\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(10.00, 10.00)\n>>> turtle.towards(0,0)\n225.0\n", + "Turtle.undo": "undo (repeatedly) the last turtle action.\n\nNo argument.\n\nundo (repeatedly) the last turtle action.\nNumber of available undo actions is determined by the size of\nthe undobuffer.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(4):\n... turtle.fd(50); turtle.lt(80)\n...\n>>> for i in range(8):\n... turtle.undo()\n...\n", + "Turtle.undobufferentries": "Return count of entries in the undobuffer.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> while undobufferentries():\n... undo()\n", + "Turtle.write": "Write text at the current turtle position.\n\nArguments:\narg -- info, which is to be written to the TurtleScreen\nmove (optional) -- True/False\nalign (optional) -- one of the strings \"left\", \"center\" or right\"\nfont (optional) -- a triple (fontname, fontsize, fonttype)\n\nWrite text - the string representation of arg - at the current\nturtle position according to align (\"left\", \"center\" or right\")\nand with the given font.\nIf move is True, the pen is moved to the bottom-right corner\nof the text. By default, move is False.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.write('Home = ', True, align=\"center\")\n>>> turtle.write((0,0), True)\n", + "Turtle.xcor": "Return the turtle's x coordinate.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print turtle.xcor()\n50.0\n", + "Turtle.ycor": "Return the turtle's y coordinate\n---\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print turtle.ycor()\n86.6025403784\n", + "TurtleScreen": "Provides screen oriented methods like bgcolor etc.\n\nOnly relies upon the methods of TurtleScreenBase and NOT\nupon components of the underlying graphics toolkit -\nwhich is Tkinter in this case.\n", + "Vec2D": "A 2 dimensional vector class, used as a helper class\nfor implementing turtle graphics.\nMay be useful for turtle graphics programs also.\nDerived from tuple, so a vector is a tuple!\n\nProvides (for a, b vectors, k number):\n a+b vector addition\n a-b vector subtraction\n a*b inner product\n k*a and a*k multiplication with scalar\n |a| absolute value of a\n a.rotate(angle) rotation\n", + "_Screen.bgcolor": "Set or return backgroundcolor of the TurtleScreen.\n\nArguments (if given): a color string or three numbers\nin the range 0..colormode or a 3-tuple of such numbers.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgcolor(\"orange\")\n>>> screen.bgcolor()\n'orange'\n>>> screen.bgcolor(0.5,0,0.5)\n>>> screen.bgcolor()\n'#800080'\n", + "_Screen.bgpic": "Set background image or return name of current backgroundimage.\n\nOptional argument:\npicname -- a string, name of a gif-file or \"nopic\".\n\nIf picname is a filename, set the corresponding image as background.\nIf picname is \"nopic\", delete backgroundimage, if present.\nIf picname is None, return the filename of the current backgroundimage.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgpic()\n'nopic'\n>>> screen.bgpic(\"landscape.gif\")\n>>> screen.bgpic()\n'landscape.gif'\n", + "_Screen.bye": "Shut the turtlegraphics window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bye()\n", + "_Screen.clearscreen": "Delete all drawings and all turtles from the TurtleScreen.\n\nNo argument.\n\nReset empty TurtleScreen to its initial state: white background,\nno backgroundimage, no eventbindings and tracing on.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.clear()\n\nNote: this method is not available as function.\n", + "_Screen.colormode": "Return the colormode or set it to 1.0 or 255.\n\nOptional argument:\ncmode -- one of the values 1.0 or 255\n\nr, g, b values of colortriples have to be in range 0..cmode.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.colormode()\n1.0\n>>> screen.colormode(255)\n>>> pencolor(240,160,80)\n", + "_Screen.delay": "Return or set the drawing delay in milliseconds.\n\nOptional argument:\ndelay -- positive integer\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.delay(15)\n>>> screen.delay()\n15\n", + "_Screen.exitonclick": "Go into mainloop until the mouse is clicked.\n\nNo arguments.\n\nBind bye() method to mouseclick on TurtleScreen.\nIf \"using_IDLE\" - value in configuration dictionary is False\n(default value), enter mainloop.\nIf IDLE with -n switch (no subprocess) is used, this value should be\nset to True in turtle.cfg. In this case IDLE's mainloop\nis active also for the client script.\n\nThis is a method of the Screen-class and not available for\nTurtleScreen instances.\n\nExample (for a Screen instance named screen):\n>>> screen.exitonclick()\n\n", + "_Screen.getcanvas": "Return the Canvas of this TurtleScreen.\n\nNo argument.\n\nExample (for a Screen instance named screen):\n>>> cv = screen.getcanvas()\n>>> cv\n\n", + "_Screen.getshapes": "Return a list of names of all currently available turtle shapes.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.getshapes()\n['arrow', 'blank', 'circle', ... , 'turtle']\n", + "_Screen.listen": "Set focus on TurtleScreen (in order to collect key-events)\n\nNo arguments.\nDummy arguments are provided in order\nto be able to pass listen to the onclick method.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.listen()\n", + "_Screen.mainloop": "Starts event loop - calling Tkinter's mainloop function.\n\nNo argument.\n\nMust be last statement in a turtle graphics program.\nMust NOT be used if a script is run from within IDLE in -n mode\n(No subprocess) - for interactive use of turtle graphics.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.mainloop()\n\n", + "_Screen.mode": "Set turtle-mode ('standard', 'logo' or 'world') and perform reset.\n\nOptional argument:\nmode -- one of the strings 'standard', 'logo' or 'world'\n\nMode 'standard' is compatible with turtle.py.\nMode 'logo' is compatible with most Logo-Turtle-Graphics.\nMode 'world' uses userdefined 'worldcoordinates'. *Attention*: in\nthis mode angles appear distorted if x/y unit-ratio doesn't equal 1.\nIf mode is not given, return the current mode.\n\n Mode Initial turtle heading positive angles\n ------------|-------------------------|-------------------\n 'standard' to the right (east) counterclockwise\n 'logo' upward (north) clockwise\n\nExamples:\n>>> mode('logo') # resets turtle heading to north\n>>> mode()\n'logo'\n", + "_Screen.numinput": "Pop up a dialog window for input of a number.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what numerical information to input.\ndefault: default value\nminval: minimum value for input\nmaxval: maximum value for input\n\nThe number input must be in the range minval .. maxval if these are\ngiven. If not, a hint is issued and the dialog remains open for\ncorrection. Return the number input.\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.numinput(\"Poker\", \"Your stakes:\", 1000, minval=10, maxval=10000)\n\n", + "_Screen.onkey": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onkeypress": "Bind fun to key-press event of key if key is given,\nor to any key-press-event if no key is given.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen\nand a Turtle instance named turtle):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkeypress(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, or by keeping pressed the up-arrow key.\nconsequently drawing a hexagon.\n", + "_Screen.onkeyrelease": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onscreenclick": "Bind fun to mouse-click event on canvas.\n\nArguments:\nfun -- a function with two arguments, the coordinates of the\n clicked point on the canvas.\nbtn -- the number of the mouse-button, defaults to 1\n\nExample (for a TurtleScreen instance named screen)\n\n>>> screen.onclick(goto)\n>>> # Subsequently clicking into the TurtleScreen will\n>>> # make the turtle move to the clicked point.\n>>> screen.onclick(None)\n", + "_Screen.ontimer": "Install a timer, which calls fun after t milliseconds.\n\nArguments:\nfun -- a function with no arguments.\nt -- a number >= 0\n\nExample (for a TurtleScreen instance named screen):\n\n>>> running = True\n>>> def f():\n... if running:\n... fd(50)\n... lt(60)\n... screen.ontimer(f, 250)\n...\n>>> f() # makes the turtle marching around\n>>> running = False\n", + "_Screen.register_shape": "Adds a turtle shape to TurtleScreen's shapelist.\n\nArguments:\n(1) name is the name of a gif-file and shape is None.\n Installs the corresponding image shape.\n !! Image-shapes DO NOT rotate when turning the turtle,\n !! so they do not display the heading of the turtle!\n(2) name is an arbitrary string and shape is a tuple\n of pairs of coordinates. Installs the corresponding\n polygon shape\n(3) name is an arbitrary string and shape is a\n (compound) Shape object. Installs the corresponding\n compound shape.\nTo use a shape, you have to issue the command shape(shapename).\n\ncall: register_shape(\"turtle.gif\")\n--or: register_shape(\"tri\", ((0,0), (10,10), (-10,10)))\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.register_shape(\"triangle\", ((5,-3),(0,5),(-5,-3)))\n\n", + "_Screen.resetscreen": "Reset all Turtles on the Screen to their initial state.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.reset()\n", + "_Screen.screensize": "Resize the canvas the turtles are drawing on.\n\nOptional arguments:\ncanvwidth -- positive integer, new width of canvas in pixels\ncanvheight -- positive integer, new height of canvas in pixels\nbg -- colorstring or color-tuple, new backgroundcolor\nIf no arguments are given, return current (canvaswidth, canvasheight)\n\nDo not alter the drawing window. To observe hidden parts of\nthe canvas use the scrollbars. (Can make visible those parts\nof a drawing, which were outside the canvas before!)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.screensize(2000,1500)\n>>> # e.g. to search for an erroneously escaped turtle ;-)\n", + "_Screen.setup": "Set the size and position of the main window.\n\nArguments:\nwidth: as integer a size in pixels, as float a fraction of the screen.\n Default is 50% of screen.\nheight: as integer the height in pixels, as float a fraction of the\n screen. Default is 75% of screen.\nstartx: if positive, starting position in pixels from the left\n edge of the screen, if negative from the right edge\n Default, startx=None is to center window horizontally.\nstarty: if positive, starting position in pixels from the top\n edge of the screen, if negative from the bottom edge\n Default, starty=None is to center window vertically.\n\nExamples (for a Screen instance named screen):\n>>> screen.setup (width=200, height=200, startx=0, starty=0)\n\nsets window to 200x200 pixels, in upper left of screen\n\n>>> screen.setup(width=.75, height=0.5, startx=None, starty=None)\n\nsets window to 75% of screen by 50% of screen and centers\n", + "_Screen.setworldcoordinates": "Set up a user defined coordinate-system.\n\nArguments:\nllx -- a number, x-coordinate of lower left corner of canvas\nlly -- a number, y-coordinate of lower left corner of canvas\nurx -- a number, x-coordinate of upper right corner of canvas\nury -- a number, y-coordinate of upper right corner of canvas\n\nSet up user coodinat-system and switch to mode 'world' if necessary.\nThis performs a screen.reset. If mode 'world' is already active,\nall drawings are redrawn according to the new coordinates.\n\nBut ATTENTION: in user-defined coordinatesystems angles may appear\ndistorted. (see Screen.mode())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.setworldcoordinates(-10,-0.5,50,1.5)\n>>> for _ in range(36):\n... left(10)\n... forward(0.5)\n", + "_Screen.textinput": "Pop up a dialog window for input of a string.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what information to input.\n\nReturn the string input\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.textinput(\"NIM\", \"Name of first player:\")\n\n", + "_Screen.title": "Set title of turtle-window\n\nArgument:\ntitlestring -- a string, to appear in the titlebar of the\n turtle graphics window.\n\nThis is a method of Screen-class. Not available for TurtleScreen-\nobjects.\n\nExample (for a Screen instance named screen):\n>>> screen.title(\"Welcome to the turtle-zoo!\")\n", + "_Screen.tracer": "Turns turtle animation on/off and set delay for update drawings.\n\nOptional arguments:\nn -- nonnegative integer\ndelay -- nonnegative integer\n\nIf n is given, only each n-th regular screen update is really performed.\n(Can be used to accelerate the drawing of complex graphics.)\nSecond arguments sets delay value (see RawTurtle.delay())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.tracer(8, 25)\n>>> dist = 2\n>>> for i in range(200):\n... fd(dist)\n... rt(90)\n... dist += 2\n", + "_Screen.turtles": "Return the list of turtles on the screen.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.turtles()\n[]\n", + "_Screen.update": "Perform a TurtleScreen update.\n ", + "_Screen.window_height": "Return the height of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_height()\n480\n", + "_Screen.window_width": "Return the width of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_width()\n640\n", + "write_docstringdict": "Create and write docstring-dictionary to file.\n\nOptional argument:\nfilename -- a string, used as filename\n default value is turtle_docstringdict\n\nHas to be called explicitly, (not used by the turtle-graphics classes)\nThe docstring dictionary will be written to the Python script .py\nIt is intended to serve as a template for translation of the docstrings\ninto different languages.\n" + }, + "3.12": { + "RawTurtle": "Animation part of the RawTurtle.\nPuts RawTurtle upon a TurtleScreen and provides tools for\nits animation.\n", + "Screen": "Return the singleton screen object.\nIf none exists at the moment, create a new one and return it,\nelse return the existing one.", + "ScrolledCanvas": "Modeled after the scrolled canvas class from Grayons's Tkinter book.\n\nUsed as the default canvas, which pops up automatically when\nusing turtle graphics functions or the Turtle class.\n", + "Shape": "Data structure modeling shapes.\n\nattribute _type is one of \"polygon\", \"image\", \"compound\"\nattribute _data is - depending on _type a poygon-tuple,\nan image or a list constructed using the addcomponent method.\n", + "Terminator": "Will be raised in TurtleScreen.update, if _RUNNING becomes False.\n\nThis stops execution of a turtle graphics script.\nMain purpose: use in the Demo-Viewer turtle.Demo.py.\n", + "Turtle": "RawTurtle auto-creating (scrolled) canvas.\n\nWhen a Turtle object is created or a function derived from some\nTurtle method is called a TurtleScreen object is automatically created.\n", + "Turtle.back": "Move the turtle backward by distance.\n\nAliases: back | backward | bk\n\nArgument:\ndistance -- a number\n\nMove the turtle backward by distance, opposite to the direction the\nturtle is headed. Do not change the turtle's heading.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 0.00)\n>>> turtle.backward(30)\n>>> turtle.position()\n(-30.00, 0.00)\n", + "Turtle.begin_fill": "Called just before drawing a shape to be filled.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.begin_poly": "Start recording the vertices of a polygon.\n\nNo argument.\n\nStart recording the vertices of a polygon. Current turtle position\nis first point of polygon.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_poly()\n", + "Turtle.circle": "Draw a circle with given radius.\n\nArguments:\nradius -- a number\nextent (optional) -- a number\nsteps (optional) -- an integer\n\nDraw a circle with given radius. The center is radius units left\nof the turtle; extent - an angle - determines which part of the\ncircle is drawn. If extent is not given, draw the entire circle.\nIf extent is not a full circle, one endpoint of the arc is the\ncurrent pen position. Draw the arc in counterclockwise direction\nif radius is positive, otherwise in clockwise direction. Finally\nthe direction of the turtle is changed by the amount of extent.\n\nAs the circle is approximated by an inscribed regular polygon,\nsteps determines the number of steps to use. If not given,\nit will be calculated automatically. Maybe used to draw regular\npolygons.\n\ncall: circle(radius) # full circle\n--or: circle(radius, extent) # arc\n--or: circle(radius, extent, steps)\n--or: circle(radius, steps=6) # 6-sided polygon\n\nExample (for a Turtle instance named turtle):\n>>> turtle.circle(50)\n>>> turtle.circle(120, 180) # semicircle\n", + "Turtle.clear": "Delete the turtle's drawings from the screen. Do not move turtle.\n\nNo arguments.\n\nDelete the turtle's drawings from the screen. Do not move turtle.\nState and position of the turtle as well as drawings of other\nturtles are not affected.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.clear()\n", + "Turtle.clearstamp": "Delete stamp with given stampid\n\nArgument:\nstampid - an integer, must be return value of previous stamp() call.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> astamp = turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.clearstamp(astamp)\n", + "Turtle.clearstamps": "Delete all or first/last n of turtle's stamps.\n\nOptional argument:\nn -- an integer\n\nIf n is None, delete all of pen's stamps,\nelse if n > 0 delete first n stamps\nelse if n < 0 delete last n stamps.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(8):\n... turtle.stamp(); turtle.fd(30)\n...\n>>> turtle.clearstamps(2)\n>>> turtle.clearstamps(-2)\n>>> turtle.clearstamps()\n", + "Turtle.clone": "Create and return a clone of the turtle.\n\nNo argument.\n\nCreate and return a clone of the turtle with same position, heading\nand turtle properties.\n\nExample (for a Turtle instance named mick):\nmick = Turtle()\njoe = mick.clone()\n", + "Turtle.color": "Return or set the pencolor and fillcolor.\n\nArguments:\nSeveral input formats are allowed.\nThey use 0, 1, 2, or 3 arguments as follows:\n\ncolor()\n Return the current pencolor and the current fillcolor\n as a pair of color specification strings as are returned\n by pencolor and fillcolor.\ncolor(colorstring), color((r,g,b)), color(r,g,b)\n inputs as in pencolor, set both, fillcolor and pencolor,\n to the given value.\ncolor(colorstring1, colorstring2),\ncolor((r1,g1,b1), (r2,g2,b2))\n equivalent to pencolor(colorstring1) and fillcolor(colorstring2)\n and analogously, if the other input format is used.\n\nIf turtleshape is a polygon, outline and interior of that polygon\nis drawn with the newly set colors.\nFor more info see: pencolor, fillcolor\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color('red', 'green')\n>>> turtle.color()\n('red', 'green')\n>>> colormode(255)\n>>> color((40, 80, 120), (160, 200, 240))\n>>> color()\n('#285078', '#a0c8f0')\n", + "Turtle.degrees": "Set angle measurement units to degrees.\n\nOptional argument:\nfullcircle - a number\n\nSet angle measurement units, i. e. set number\nof 'degrees' for a full circle. Default value is\n360 degrees.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(90)\n>>> turtle.heading()\n90\n\nChange angle measurement unit to grad (also known as gon,\ngrade, or gradian and equals 1/100-th of the right angle.)\n>>> turtle.degrees(400.0)\n>>> turtle.heading()\n100\n\n", + "Turtle.distance": "Return the distance from the turtle to (x,y) in turtle step units.\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00, 0.00)\n>>> turtle.distance(30,40)\n50.0\n>>> pen = Turtle()\n>>> pen.forward(77)\n>>> turtle.distance(pen)\n77.0\n", + "Turtle.dot": "Draw a dot with diameter size, using color.\n\nOptional arguments:\nsize -- an integer >= 1 (if given)\ncolor -- a colorstring or a numeric color tuple\n\nDraw a circular dot with diameter size, using color.\nIf size is not given, the maximum of pensize+4 and 2*pensize is used.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.dot()\n>>> turtle.fd(50); turtle.dot(20, \"blue\"); turtle.fd(50)\n", + "Turtle.down": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.end_fill": "Fill the shape drawn after the call begin_fill().\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.end_poly": "Stop recording the vertices of a polygon.\n\nNo argument.\n\nStop recording the vertices of a polygon. Current turtle position is\nlast point of polygon. This will be connected with the first point.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.end_poly()\n", + "Turtle.fillcolor": "Return or set the fillcolor.\n\nArguments:\nFour input formats are allowed:\n - fillcolor()\n Return the current fillcolor as color specification string,\n possibly in hex-number format (see example).\n May be used as input to another color/pencolor/fillcolor call.\n - fillcolor(colorstring)\n s is a Tk color specification string, such as \"red\" or \"yellow\"\n - fillcolor((r, g, b))\n *a tuple* of r, g, and b, which represent, an RGB color,\n and each of r, g, and b are in the range 0..colormode,\n where colormode is either 1.0 or 255\n - fillcolor(r, g, b)\n r, g, and b represent an RGB color, and each of r, g, and b\n are in the range 0..colormode\n\nIf turtleshape is a polygon, the interior of that polygon is drawn\nwith the newly set fillcolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.fillcolor('violet')\n>>> col = turtle.pencolor()\n>>> turtle.fillcolor(col)\n>>> turtle.fillcolor(0, .5, 0)\n", + "Turtle.filling": "Return fillstate (True if filling, False else).\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_fill()\n>>> if turtle.filling():\n... turtle.pensize(5)\n... else:\n... turtle.pensize(3)\n", + "Turtle.forward": "Move the turtle forward by the specified distance.\n\nAliases: forward | fd\n\nArgument:\ndistance -- a number (integer or float)\n\nMove the turtle forward by the specified distance, in the direction\nthe turtle is headed.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 0.00)\n>>> turtle.forward(25)\n>>> turtle.position()\n(25.00,0.00)\n>>> turtle.forward(-75)\n>>> turtle.position()\n(-50.00,0.00)\n", + "Turtle.get_poly": "Return the lastly recorded polygon.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> p = turtle.get_poly()\n>>> turtle.register_shape(\"myFavouriteShape\", p)\n", + "Turtle.get_shapepoly": "Return the current shape polygon as tuple of coordinate pairs.\n\nNo argument.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapetransform(4, -1, 0, 2)\n>>> turtle.get_shapepoly()\n((50, -20), (30, 20), (-50, 20), (-30, -20))\n\n", + "Turtle.getpen": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.getscreen": "Return the TurtleScreen object, the turtle is drawing on.\n\nNo argument.\n\nReturn the TurtleScreen object, the turtle is drawing on.\nSo TurtleScreen-methods can be called for that object.\n\nExample (for a Turtle instance named turtle):\n>>> ts = turtle.getscreen()\n>>> ts\n\n>>> ts.bgcolor(\"pink\")\n", + "Turtle.getturtle": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.goto": "Move turtle to an absolute position.\n\nAliases: setpos | setposition | goto:\n\nArguments:\nx -- a number or a pair/vector of numbers\ny -- a number None\n\ncall: goto(x, y) # two coordinates\n--or: goto((x, y)) # a pair (tuple) of coordinates\n--or: goto(vec) # e.g. as returned by pos()\n\nMove turtle to an absolute position. If the pen is down,\na line will be drawn. The turtle's orientation does not change.\n\nExample (for a Turtle instance named turtle):\n>>> tp = turtle.pos()\n>>> tp\n(0.00, 0.00)\n>>> turtle.setpos(60,30)\n>>> turtle.pos()\n(60.00,30.00)\n>>> turtle.setpos((20,80))\n>>> turtle.pos()\n(20.00,80.00)\n>>> turtle.setpos(tp)\n>>> turtle.pos()\n(0.00,0.00)\n", + "Turtle.heading": "Return the turtle's current heading.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(67)\n>>> turtle.heading()\n67.0\n", + "Turtle.hideturtle": "Makes the turtle invisible.\n\nAliases: hideturtle | ht\n\nNo argument.\n\nIt's a good idea to do this while you're in the\nmiddle of a complicated drawing, because hiding\nthe turtle speeds up the drawing observably.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n", + "Turtle.home": "Move turtle to the origin - coordinates (0,0).\n\nNo arguments.\n\nMove turtle to the origin - coordinates (0,0) and set its\nheading to its start-orientation (which depends on mode).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.home()\n", + "Turtle.isdown": "Return True if pen is down, False if it's up.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n>>> turtle.isdown()\nFalse\n>>> turtle.pendown()\n>>> turtle.isdown()\nTrue\n", + "Turtle.isvisible": "Return True if the Turtle is shown, False if it's hidden.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> print(turtle.isvisible())\nFalse\n", + "Turtle.left": "Turn turtle left by angle units.\n\nAliases: left | lt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle left by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.left(45)\n>>> turtle.heading()\n67.0\n", + "Turtle.onclick": "Bind fun to mouse-click event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\nadd -- True or False. If True, new binding will be added, otherwise\n it will replace a former binding.\n\nExample for the anonymous turtle, i. e. the procedural way:\n\n>>> def turn(x, y):\n... left(360)\n...\n>>> onclick(turn) # Now clicking into the turtle will turn it.\n>>> onclick(None) # event-binding will be removed\n", + "Turtle.ondrag": "Bind fun to mouse-move event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nEvery sequence of mouse-move-events on a turtle is preceded by a\nmouse-click event on that turtle.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.ondrag(turtle.goto)\n\nSubsequently clicking and dragging a Turtle will move it\nacross the screen thereby producing handdrawings (if pen is\ndown).\n", + "Turtle.onrelease": "Bind fun to mouse-button-release event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nExample (for a MyTurtle instance named joe):\n>>> class MyTurtle(Turtle):\n... def glow(self,x,y):\n... self.fillcolor(\"red\")\n... def unglow(self,x,y):\n... self.fillcolor(\"\")\n...\n>>> joe = MyTurtle()\n>>> joe.onclick(joe.glow)\n>>> joe.onrelease(joe.unglow)\n\nClicking on joe turns fillcolor red, unclicking turns it to\ntransparent.\n", + "Turtle.pen": "Return or set the pen's attributes.\n\nArguments:\n pen -- a dictionary with some or all of the below listed keys.\n **pendict -- one or more keyword-arguments with the below\n listed keys as keywords.\n\nReturn or set the pen's attributes in a 'pen-dictionary'\nwith the following key/value pairs:\n \"shown\" : True/False\n \"pendown\" : True/False\n \"pencolor\" : color-string or color-tuple\n \"fillcolor\" : color-string or color-tuple\n \"pensize\" : positive number\n \"speed\" : number in range 0..10\n \"resizemode\" : \"auto\" or \"user\" or \"noresize\"\n \"stretchfactor\": (positive number, positive number)\n \"shearfactor\": number\n \"outline\" : positive number\n \"tilt\" : number\n\nThis dictionary can be used as argument for a subsequent\npen()-call to restore the former pen-state. Moreover one\nor more of these attributes can be provided as keyword-arguments.\nThis can be used to set several pen attributes in one statement.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.pen(fillcolor=\"black\", pencolor=\"red\", pensize=10)\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> penstate=turtle.pen()\n>>> turtle.color(\"yellow\",\"\")\n>>> turtle.penup()\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> p.pen(penstate, fillcolor=\"green\")\n>>> p.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n", + "Turtle.pencolor": "Return or set the pencolor.\n\nArguments:\nFour input formats are allowed:\n - pencolor()\n Return the current pencolor as color specification string,\n possibly in hex-number format (see example).\n May be used as input to another color/pencolor/fillcolor call.\n - pencolor(colorstring)\n s is a Tk color specification string, such as \"red\" or \"yellow\"\n - pencolor((r, g, b))\n *a tuple* of r, g, and b, which represent, an RGB color,\n and each of r, g, and b are in the range 0..colormode,\n where colormode is either 1.0 or 255\n - pencolor(r, g, b)\n r, g, and b represent an RGB color, and each of r, g, and b\n are in the range 0..colormode\n\nIf turtleshape is a polygon, the outline of that polygon is drawn\nwith the newly set pencolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pencolor('brown')\n>>> tup = (0.2, 0.8, 0.55)\n>>> turtle.pencolor(tup)\n>>> turtle.pencolor()\n'#33cc8c'\n", + "Turtle.pendown": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.pensize": "Set or return the line thickness.\n\nAliases: pensize | width\n\nArgument:\nwidth -- positive number\n\nSet the line thickness to width or return it. If resizemode is set\nto \"auto\" and turtleshape is a polygon, that polygon is drawn with\nthe same line thickness. If no argument is given, current pensize\nis returned.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pensize()\n1\n>>> turtle.pensize(10) # from here on lines of width 10 are drawn\n", + "Turtle.penup": "Pull the pen up -- no drawing when moving.\n\nAliases: penup | pu | up\n\nNo argument\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n", + "Turtle.position": "Return the turtle's current location (x,y), as a Vec2D-vector.\n\nAliases: pos | position\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00, 240.00)\n", + "Turtle.radians": "Set the angle measurement units to radians.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n90\n>>> turtle.radians()\n>>> turtle.heading()\n1.5707963267948966\n", + "Turtle.reset": "Delete the turtle's drawings and restore its default values.\n\nNo argument.\n\nDelete the turtle's drawings from the screen, re-center the turtle\nand set variables to the default values.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,-22.00)\n>>> turtle.heading()\n100.0\n>>> turtle.reset()\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.heading()\n0.0\n", + "Turtle.resizemode": "Set resizemode to one of the values: \"auto\", \"user\", \"noresize\".\n\n(Optional) Argument:\nrmode -- one of the strings \"auto\", \"user\", \"noresize\"\n\nDifferent resizemodes have the following effects:\n - \"auto\" adapts the appearance of the turtle\n corresponding to the value of pensize.\n - \"user\" adapts the appearance of the turtle according to the\n values of stretchfactor and outlinewidth (outline),\n which are set by shapesize()\n - \"noresize\" no adaption of the turtle's appearance takes place.\nIf no argument is given, return current resizemode.\nresizemode(\"user\") is called by a call of shapesize with arguments.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"noresize\")\n>>> turtle.resizemode()\n'noresize'\n", + "Turtle.right": "Turn turtle right by angle units.\n\nAliases: right | rt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle right by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.right(45)\n>>> turtle.heading()\n337.0\n", + "Turtle.setheading": "Set the orientation of the turtle to to_angle.\n\nAliases: setheading | seth\n\nArgument:\nto_angle -- a number (integer or float)\n\nSet the orientation of the turtle to to_angle.\nHere are some common directions in degrees:\n\n standard - mode: logo-mode:\n-------------------|--------------------\n 0 - east 0 - north\n 90 - north 90 - east\n 180 - west 180 - south\n 270 - south 270 - west\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setheading(90)\n>>> turtle.heading()\n90\n", + "Turtle.settiltangle": "Rotate the turtleshape to point in the specified direction\n\nArgument: angle -- number\n\nRotate the turtleshape to point in the direction specified by angle,\nregardless of its current tilt-angle. DO NOT change the turtle's\nheading (direction of movement).\n\nDeprecated since Python 3.1\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.settiltangle(45)\n>>> turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.settiltangle(-45)\n>>> turtle.stamp()\n>>> turtle.fd(50)\n", + "Turtle.setundobuffer": "Set or disable undobuffer.\n\nArgument:\nsize -- an integer or None\n\nIf size is an integer an empty undobuffer of given size is installed.\nSize gives the maximum number of turtle-actions that can be undone\nby the undo() function.\nIf size is None, no undobuffer is present.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setundobuffer(42)\n", + "Turtle.setx": "Set the turtle's first coordinate to x\n\nArgument:\nx -- a number (integer or float)\n\nSet the turtle's first coordinate to x, leave second coordinate\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 240.00)\n>>> turtle.setx(10)\n>>> turtle.position()\n(10.00, 240.00)\n", + "Turtle.sety": "Set the turtle's second coordinate to y\n\nArgument:\ny -- a number (integer or float)\n\nSet the turtle's first coordinate to x, second coordinate remains\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 40.00)\n>>> turtle.sety(-10)\n>>> turtle.position()\n(0.00, -10.00)\n", + "Turtle.shape": "Set turtle shape to shape with given name / return current shapename.\n\nOptional argument:\nname -- a string, which is a valid shapename\n\nSet turtle shape to shape with given name or, if name is not given,\nreturn name of current shape.\nShape with name must exist in the TurtleScreen's shape dictionary.\nInitially there are the following polygon shapes:\n'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'.\nTo learn about how to deal with shapes see Screen-method register_shape.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.shape()\n'arrow'\n>>> turtle.shape(\"turtle\")\n>>> turtle.shape()\n'turtle'\n", + "Turtle.shapesize": "Set/return turtle's stretchfactors/outline. Set resizemode to \"user\".\n\nOptional arguments:\n stretch_wid : positive number\n stretch_len : positive number\n outline : positive number\n\nReturn or set the pen's attributes x/y-stretchfactors and/or outline.\nSet resizemode to \"user\".\nIf and only if resizemode is set to \"user\", the turtle will be displayed\nstretched according to its stretchfactors:\nstretch_wid is stretchfactor perpendicular to orientation\nstretch_len is stretchfactor in direction of turtles orientation.\noutline determines the width of the shapes's outline.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"user\")\n>>> turtle.shapesize(5, 5, 12)\n>>> turtle.shapesize(outline=8)\n", + "Turtle.shapetransform": "Set or return the current transformation matrix of the turtle shape.\n\nOptional arguments: t11, t12, t21, t22 -- numbers.\n\nIf none of the matrix elements are given, return the transformation\nmatrix.\nOtherwise set the given elements and transform the turtleshape\naccording to the matrix consisting of first row t11, t12 and\nsecond row t21, 22.\nModify stretchfactor, shearfactor and tiltangle according to the\ngiven matrix.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapesize(4,2)\n>>> turtle.shearfactor(-0.5)\n>>> turtle.shapetransform()\n(4.0, -1.0, -0.0, 2.0)\n", + "Turtle.shearfactor": "Set or return the current shearfactor.\n\nOptional argument: shear -- number, tangent of the shear angle\n\nShear the turtleshape according to the given shearfactor shear,\nwhich is the tangent of the shear angle. DO NOT change the\nturtle's heading (direction of movement).\nIf shear is not given: return the current shearfactor, i. e. the\ntangent of the shear angle, by which lines parallel to the\nheading of the turtle are sheared.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.shearfactor(0.5)\n>>> turtle.shearfactor()\n>>> 0.5\n", + "Turtle.showturtle": "Makes the turtle visible.\n\nAliases: showturtle | st\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> turtle.showturtle()\n", + "Turtle.speed": "Return or set the turtle's speed.\n\nOptional argument:\nspeed -- an integer in the range 0..10 or a speedstring (see below)\n\nSet the turtle's speed to an integer value in the range 0 .. 10.\nIf no argument is given: return current speed.\n\nIf input is a number greater than 10 or smaller than 0.5,\nspeed is set to 0.\nSpeedstrings are mapped to speedvalues in the following way:\n 'fastest' : 0\n 'fast' : 10\n 'normal' : 6\n 'slow' : 3\n 'slowest' : 1\nspeeds from 1 to 10 enforce increasingly faster animation of\nline drawing and turtle turning.\n\nAttention:\nspeed = 0 : *no* animation takes place. forward/back makes turtle jump\nand likewise left/right make the turtle turn instantly.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.speed(3)\n", + "Turtle.stamp": "Stamp a copy of the turtleshape onto the canvas and return its id.\n\nNo argument.\n\nStamp a copy of the turtle shape onto the canvas at the current\nturtle position. Return a stamp_id for that stamp, which can be\nused to delete it by calling clearstamp(stamp_id).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> turtle.stamp()\n13\n>>> turtle.fd(50)\n", + "Turtle.teleport": "Instantly move turtle to an absolute position.\n\nArguments:\nx -- a number or None\ny -- a number None\nfill_gap -- a boolean This argument must be specified by name.\n\ncall: teleport(x, y) # two coordinates\n--or: teleport(x) # teleport to x position, keeping y as is\n--or: teleport(y=y) # teleport to y position, keeping x as is\n--or: teleport(x, y, fill_gap=True)\n # teleport but fill the gap in between\n\nMove turtle to an absolute position. Unlike goto(x, y), a line will not\nbe drawn. The turtle's orientation does not change. If currently\nfilling, the polygon(s) teleported from will be filled after leaving,\nand filling will begin again after teleporting. This can be disabled\nwith fill_gap=True, which makes the imaginary line traveled during\nteleporting act as a fill barrier like in goto(x, y).\n\nExample (for a Turtle instance named turtle):\n>>> tp = turtle.pos()\n>>> tp\n(0.00,0.00)\n>>> turtle.teleport(60)\n>>> turtle.pos()\n(60.00,0.00)\n>>> turtle.teleport(y=10)\n>>> turtle.pos()\n(60.00,10.00)\n>>> turtle.teleport(20, 30)\n>>> turtle.pos()\n(20.00,30.00)\n", + "Turtle.tilt": "Rotate the turtleshape by angle.\n\nArgument:\nangle - a number\n\nRotate the turtleshape by angle from its current tilt-angle,\nbut do NOT change the turtle's heading (direction of movement).\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n", + "Turtle.tiltangle": "Set or return the current tilt-angle.\n\nOptional argument: angle -- number\n\nRotate the turtleshape to point in the direction specified by angle,\nregardless of its current tilt-angle. DO NOT change the turtle's\nheading (direction of movement).\nIf angle is not given: return the current tilt-angle, i. e. the angle\nbetween the orientation of the turtleshape and the heading of the\nturtle (its direction of movement).\n\n(Incorrectly marked as deprecated since Python 3.1, it is really\nsettiltangle that is deprecated.)\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5, 2)\n>>> turtle.tiltangle()\n0.0\n>>> turtle.tiltangle(45)\n>>> turtle.tiltangle()\n45.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.tiltangle(-45)\n>>> turtle.tiltangle()\n315.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n", + "Turtle.towards": "Return the angle of the line from the turtle's position to (x, y).\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nReturn the angle, between the line from turtle-position to position\nspecified by x, y and the turtle's start orientation. (Depends on\nmodes - \"standard\" or \"logo\")\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(10.00, 10.00)\n>>> turtle.towards(0,0)\n225.0\n", + "Turtle.undo": "undo (repeatedly) the last turtle action.\n\nNo argument.\n\nundo (repeatedly) the last turtle action.\nNumber of available undo actions is determined by the size of\nthe undobuffer.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(4):\n... turtle.fd(50); turtle.lt(80)\n...\n>>> for i in range(8):\n... turtle.undo()\n...\n", + "Turtle.undobufferentries": "Return count of entries in the undobuffer.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> while undobufferentries():\n... undo()\n", + "Turtle.write": "Write text at the current turtle position.\n\nArguments:\narg -- info, which is to be written to the TurtleScreen\nmove (optional) -- True/False\nalign (optional) -- one of the strings \"left\", \"center\" or right\"\nfont (optional) -- a triple (fontname, fontsize, fonttype)\n\nWrite text - the string representation of arg - at the current\nturtle position according to align (\"left\", \"center\" or right\")\nand with the given font.\nIf move is True, the pen is moved to the bottom-right corner\nof the text. By default, move is False.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.write('Home = ', True, align=\"center\")\n>>> turtle.write((0,0), True)\n", + "Turtle.xcor": "Return the turtle's x coordinate.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print(turtle.xcor())\n50.0\n", + "Turtle.ycor": "Return the turtle's y coordinate\n---\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print(turtle.ycor())\n86.6025403784\n", + "TurtleScreen": "Provides screen oriented methods like bgcolor etc.\n\nOnly relies upon the methods of TurtleScreenBase and NOT\nupon components of the underlying graphics toolkit -\nwhich is Tkinter in this case.\n", + "Vec2D": "A 2 dimensional vector class, used as a helper class\nfor implementing turtle graphics.\nMay be useful for turtle graphics programs also.\nDerived from tuple, so a vector is a tuple!\n\nProvides (for a, b vectors, k number):\n a+b vector addition\n a-b vector subtraction\n a*b inner product\n k*a and a*k multiplication with scalar\n |a| absolute value of a\n a.rotate(angle) rotation\n", + "_Screen.bgcolor": "Set or return backgroundcolor of the TurtleScreen.\n\nArguments (if given): a color string or three numbers\nin the range 0..colormode or a 3-tuple of such numbers.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgcolor(\"orange\")\n>>> screen.bgcolor()\n'orange'\n>>> screen.bgcolor(0.5,0,0.5)\n>>> screen.bgcolor()\n'#800080'\n", + "_Screen.bgpic": "Set background image or return name of current backgroundimage.\n\nOptional argument:\npicname -- a string, name of a gif-file or \"nopic\".\n\nIf picname is a filename, set the corresponding image as background.\nIf picname is \"nopic\", delete backgroundimage, if present.\nIf picname is None, return the filename of the current backgroundimage.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgpic()\n'nopic'\n>>> screen.bgpic(\"landscape.gif\")\n>>> screen.bgpic()\n'landscape.gif'\n", + "_Screen.bye": "Shut the turtlegraphics window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bye()\n", + "_Screen.clearscreen": "Delete all drawings and all turtles from the TurtleScreen.\n\nNo argument.\n\nReset empty TurtleScreen to its initial state: white background,\nno backgroundimage, no eventbindings and tracing on.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.clear()\n\nNote: this method is not available as function.\n", + "_Screen.colormode": "Return the colormode or set it to 1.0 or 255.\n\nOptional argument:\ncmode -- one of the values 1.0 or 255\n\nr, g, b values of colortriples have to be in range 0..cmode.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.colormode()\n1.0\n>>> screen.colormode(255)\n>>> pencolor(240,160,80)\n", + "_Screen.delay": "Return or set the drawing delay in milliseconds.\n\nOptional argument:\ndelay -- positive integer\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.delay(15)\n>>> screen.delay()\n15\n", + "_Screen.exitonclick": "Go into mainloop until the mouse is clicked.\n\nNo arguments.\n\nBind bye() method to mouseclick on TurtleScreen.\nIf \"using_IDLE\" - value in configuration dictionary is False\n(default value), enter mainloop.\nIf IDLE with -n switch (no subprocess) is used, this value should be\nset to True in turtle.cfg. In this case IDLE's mainloop\nis active also for the client script.\n\nThis is a method of the Screen-class and not available for\nTurtleScreen instances.\n\nExample (for a Screen instance named screen):\n>>> screen.exitonclick()\n\n", + "_Screen.getcanvas": "Return the Canvas of this TurtleScreen.\n\nNo argument.\n\nExample (for a Screen instance named screen):\n>>> cv = screen.getcanvas()\n>>> cv\n\n", + "_Screen.getshapes": "Return a list of names of all currently available turtle shapes.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.getshapes()\n['arrow', 'blank', 'circle', ... , 'turtle']\n", + "_Screen.listen": "Set focus on TurtleScreen (in order to collect key-events)\n\nNo arguments.\nDummy arguments are provided in order\nto be able to pass listen to the onclick method.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.listen()\n", + "_Screen.mainloop": "Starts event loop - calling Tkinter's mainloop function.\n\nNo argument.\n\nMust be last statement in a turtle graphics program.\nMust NOT be used if a script is run from within IDLE in -n mode\n(No subprocess) - for interactive use of turtle graphics.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.mainloop()\n\n", + "_Screen.mode": "Set turtle-mode ('standard', 'logo' or 'world') and perform reset.\n\nOptional argument:\nmode -- one of the strings 'standard', 'logo' or 'world'\n\nMode 'standard' is compatible with turtle.py.\nMode 'logo' is compatible with most Logo-Turtle-Graphics.\nMode 'world' uses userdefined 'worldcoordinates'. *Attention*: in\nthis mode angles appear distorted if x/y unit-ratio doesn't equal 1.\nIf mode is not given, return the current mode.\n\n Mode Initial turtle heading positive angles\n ------------|-------------------------|-------------------\n 'standard' to the right (east) counterclockwise\n 'logo' upward (north) clockwise\n\nExamples:\n>>> mode('logo') # resets turtle heading to north\n>>> mode()\n'logo'\n", + "_Screen.numinput": "Pop up a dialog window for input of a number.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what numerical information to input.\ndefault: default value\nminval: minimum value for input\nmaxval: maximum value for input\n\nThe number input must be in the range minval .. maxval if these are\ngiven. If not, a hint is issued and the dialog remains open for\ncorrection. Return the number input.\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.numinput(\"Poker\", \"Your stakes:\", 1000, minval=10, maxval=10000)\n\n", + "_Screen.onkey": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onkeypress": "Bind fun to key-press event of key if key is given,\nor to any key-press-event if no key is given.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen\nand a Turtle instance named turtle):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkeypress(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, or by keeping pressed the up-arrow key.\nconsequently drawing a hexagon.\n", + "_Screen.onkeyrelease": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onscreenclick": "Bind fun to mouse-click event on canvas.\n\nArguments:\nfun -- a function with two arguments, the coordinates of the\n clicked point on the canvas.\nbtn -- the number of the mouse-button, defaults to 1\n\nExample (for a TurtleScreen instance named screen)\n\n>>> screen.onclick(goto)\n>>> # Subsequently clicking into the TurtleScreen will\n>>> # make the turtle move to the clicked point.\n>>> screen.onclick(None)\n", + "_Screen.ontimer": "Install a timer, which calls fun after t milliseconds.\n\nArguments:\nfun -- a function with no arguments.\nt -- a number >= 0\n\nExample (for a TurtleScreen instance named screen):\n\n>>> running = True\n>>> def f():\n... if running:\n... fd(50)\n... lt(60)\n... screen.ontimer(f, 250)\n...\n>>> f() # makes the turtle marching around\n>>> running = False\n", + "_Screen.register_shape": "Adds a turtle shape to TurtleScreen's shapelist.\n\nArguments:\n(1) name is the name of a gif-file and shape is None.\n Installs the corresponding image shape.\n !! Image-shapes DO NOT rotate when turning the turtle,\n !! so they do not display the heading of the turtle!\n(2) name is an arbitrary string and shape is a tuple\n of pairs of coordinates. Installs the corresponding\n polygon shape\n(3) name is an arbitrary string and shape is a\n (compound) Shape object. Installs the corresponding\n compound shape.\nTo use a shape, you have to issue the command shape(shapename).\n\ncall: register_shape(\"turtle.gif\")\n--or: register_shape(\"tri\", ((0,0), (10,10), (-10,10)))\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.register_shape(\"triangle\", ((5,-3),(0,5),(-5,-3)))\n\n", + "_Screen.resetscreen": "Reset all Turtles on the Screen to their initial state.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.reset()\n", + "_Screen.screensize": "Resize the canvas the turtles are drawing on.\n\nOptional arguments:\ncanvwidth -- positive integer, new width of canvas in pixels\ncanvheight -- positive integer, new height of canvas in pixels\nbg -- colorstring or color-tuple, new backgroundcolor\nIf no arguments are given, return current (canvaswidth, canvasheight)\n\nDo not alter the drawing window. To observe hidden parts of\nthe canvas use the scrollbars. (Can make visible those parts\nof a drawing, which were outside the canvas before!)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.screensize(2000,1500)\n>>> # e.g. to search for an erroneously escaped turtle ;-)\n", + "_Screen.setup": "Set the size and position of the main window.\n\nArguments:\nwidth: as integer a size in pixels, as float a fraction of the screen.\n Default is 50% of screen.\nheight: as integer the height in pixels, as float a fraction of the\n screen. Default is 75% of screen.\nstartx: if positive, starting position in pixels from the left\n edge of the screen, if negative from the right edge\n Default, startx=None is to center window horizontally.\nstarty: if positive, starting position in pixels from the top\n edge of the screen, if negative from the bottom edge\n Default, starty=None is to center window vertically.\n\nExamples (for a Screen instance named screen):\n>>> screen.setup (width=200, height=200, startx=0, starty=0)\n\nsets window to 200x200 pixels, in upper left of screen\n\n>>> screen.setup(width=.75, height=0.5, startx=None, starty=None)\n\nsets window to 75% of screen by 50% of screen and centers\n", + "_Screen.setworldcoordinates": "Set up a user defined coordinate-system.\n\nArguments:\nllx -- a number, x-coordinate of lower left corner of canvas\nlly -- a number, y-coordinate of lower left corner of canvas\nurx -- a number, x-coordinate of upper right corner of canvas\nury -- a number, y-coordinate of upper right corner of canvas\n\nSet up user coodinat-system and switch to mode 'world' if necessary.\nThis performs a screen.reset. If mode 'world' is already active,\nall drawings are redrawn according to the new coordinates.\n\nBut ATTENTION: in user-defined coordinatesystems angles may appear\ndistorted. (see Screen.mode())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.setworldcoordinates(-10,-0.5,50,1.5)\n>>> for _ in range(36):\n... left(10)\n... forward(0.5)\n", + "_Screen.textinput": "Pop up a dialog window for input of a string.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what information to input.\n\nReturn the string input\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.textinput(\"NIM\", \"Name of first player:\")\n\n", + "_Screen.title": "Set title of turtle-window\n\nArgument:\ntitlestring -- a string, to appear in the titlebar of the\n turtle graphics window.\n\nThis is a method of Screen-class. Not available for TurtleScreen-\nobjects.\n\nExample (for a Screen instance named screen):\n>>> screen.title(\"Welcome to the turtle-zoo!\")\n", + "_Screen.tracer": "Turns turtle animation on/off and set delay for update drawings.\n\nOptional arguments:\nn -- nonnegative integer\ndelay -- nonnegative integer\n\nIf n is given, only each n-th regular screen update is really performed.\n(Can be used to accelerate the drawing of complex graphics.)\nSecond arguments sets delay value (see RawTurtle.delay())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.tracer(8, 25)\n>>> dist = 2\n>>> for i in range(200):\n... fd(dist)\n... rt(90)\n... dist += 2\n", + "_Screen.turtles": "Return the list of turtles on the screen.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.turtles()\n[]\n", + "_Screen.update": "Perform a TurtleScreen update.\n ", + "_Screen.window_height": "Return the height of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_height()\n480\n", + "_Screen.window_width": "Return the width of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_width()\n640\n", + "write_docstringdict": "Create and write docstring-dictionary to file.\n\nOptional argument:\nfilename -- a string, used as filename\n default value is turtle_docstringdict\n\nHas to be called explicitly, (not used by the turtle-graphics classes)\nThe docstring dictionary will be written to the Python script .py\nIt is intended to serve as a template for translation of the docstrings\ninto different languages.\n" + }, + "3.13": { + "RawTurtle": "Animation part of the RawTurtle.\nPuts RawTurtle upon a TurtleScreen and provides tools for\nits animation.\n", + "Screen": "Return the singleton screen object.\nIf none exists at the moment, create a new one and return it,\nelse return the existing one.", + "ScrolledCanvas": "Modeled after the scrolled canvas class from Grayons's Tkinter book.\n\nUsed as the default canvas, which pops up automatically when\nusing turtle graphics functions or the Turtle class.\n", + "Shape": "Data structure modeling shapes.\n\nattribute _type is one of \"polygon\", \"image\", \"compound\"\nattribute _data is - depending on _type a poygon-tuple,\nan image or a list constructed using the addcomponent method.\n", + "Terminator": "Will be raised in TurtleScreen.update, if _RUNNING becomes False.\n\nThis stops execution of a turtle graphics script.\nMain purpose: use in the Demo-Viewer turtle.Demo.py.\n", + "Turtle": "RawTurtle auto-creating (scrolled) canvas.\n\nWhen a Turtle object is created or a function derived from some\nTurtle method is called a TurtleScreen object is automatically created.\n", + "Turtle.back": "Move the turtle backward by distance.\n\nAliases: back | backward | bk\n\nArgument:\ndistance -- a number\n\nMove the turtle backward by distance, opposite to the direction the\nturtle is headed. Do not change the turtle's heading.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.backward(30)\n>>> turtle.position()\n(-30.00,0.00)\n", + "Turtle.begin_fill": "Called just before drawing a shape to be filled.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.begin_poly": "Start recording the vertices of a polygon.\n\nNo argument.\n\nStart recording the vertices of a polygon. Current turtle position\nis first point of polygon.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_poly()\n", + "Turtle.circle": "Draw a circle with given radius.\n\nArguments:\nradius -- a number\nextent (optional) -- a number\nsteps (optional) -- an integer\n\nDraw a circle with given radius. The center is radius units left\nof the turtle; extent - an angle - determines which part of the\ncircle is drawn. If extent is not given, draw the entire circle.\nIf extent is not a full circle, one endpoint of the arc is the\ncurrent pen position. Draw the arc in counterclockwise direction\nif radius is positive, otherwise in clockwise direction. Finally\nthe direction of the turtle is changed by the amount of extent.\n\nAs the circle is approximated by an inscribed regular polygon,\nsteps determines the number of steps to use. If not given,\nit will be calculated automatically. Maybe used to draw regular\npolygons.\n\ncall: circle(radius) # full circle\n--or: circle(radius, extent) # arc\n--or: circle(radius, extent, steps)\n--or: circle(radius, steps=6) # 6-sided polygon\n\nExample (for a Turtle instance named turtle):\n>>> turtle.circle(50)\n>>> turtle.circle(120, 180) # semicircle\n", + "Turtle.clear": "Delete the turtle's drawings from the screen. Do not move turtle.\n\nNo arguments.\n\nDelete the turtle's drawings from the screen. Do not move turtle.\nState and position of the turtle as well as drawings of other\nturtles are not affected.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.clear()\n", + "Turtle.clearstamp": "Delete stamp with given stampid\n\nArgument:\nstampid - an integer, must be return value of previous stamp() call.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> astamp = turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.clearstamp(astamp)\n", + "Turtle.clearstamps": "Delete all or first/last n of turtle's stamps.\n\nOptional argument:\nn -- an integer\n\nIf n is None, delete all of pen's stamps,\nelse if n > 0 delete first n stamps\nelse if n < 0 delete last n stamps.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(8):\n... turtle.stamp(); turtle.fd(30)\n...\n>>> turtle.clearstamps(2)\n>>> turtle.clearstamps(-2)\n>>> turtle.clearstamps()\n", + "Turtle.clone": "Create and return a clone of the turtle.\n\nNo argument.\n\nCreate and return a clone of the turtle with same position, heading\nand turtle properties.\n\nExample (for a Turtle instance named mick):\nmick = Turtle()\njoe = mick.clone()\n", + "Turtle.color": "Return or set the pencolor and fillcolor.\n\nArguments:\nSeveral input formats are allowed.\nThey use 0 to 3 arguments as follows:\n - color()\n Return the current pencolor and the current fillcolor as\n a pair of color specification strings or tuples as returned\n by pencolor() and fillcolor().\n - color(colorstring), color((r,g,b)), color(r,g,b)\n Inputs as in pencolor(), set both, fillcolor and pencolor,\n to the given value.\n - color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2))\n Equivalent to pencolor(colorstring1) and fillcolor(colorstring2)\n and analogously if the other input format is used.\n\nIf turtleshape is a polygon, outline and interior of that polygon\nis drawn with the newly set colors.\nFor more info see: pencolor, fillcolor\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color('red', 'green')\n>>> turtle.color()\n('red', 'green')\n>>> colormode(255)\n>>> color(('#285078', '#a0c8f0'))\n>>> color()\n((40.0, 80.0, 120.0), (160.0, 200.0, 240.0))\n", + "Turtle.degrees": "Set angle measurement units to degrees.\n\nOptional argument:\nfullcircle - a number\n\nSet angle measurement units, i. e. set number\nof 'degrees' for a full circle. Default value is\n360 degrees.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(90)\n>>> turtle.heading()\n90\n\nChange angle measurement unit to grad (also known as gon,\ngrade, or gradian and equals 1/100-th of the right angle.)\n>>> turtle.degrees(400.0)\n>>> turtle.heading()\n100\n\n", + "Turtle.distance": "Return the distance from the turtle to (x,y) in turtle step units.\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00,0.00)\n>>> turtle.distance(30,40)\n50.0\n>>> pen = Turtle()\n>>> pen.forward(77)\n>>> turtle.distance(pen)\n77.0\n", + "Turtle.dot": "Draw a dot with diameter size, using color.\n\nOptional arguments:\nsize -- an integer >= 1 (if given)\ncolor -- a colorstring or a numeric color tuple\n\nDraw a circular dot with diameter size, using color.\nIf size is not given, the maximum of pensize+4 and 2*pensize is used.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.dot()\n>>> turtle.fd(50); turtle.dot(20, \"blue\"); turtle.fd(50)\n", + "Turtle.down": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.end_fill": "Fill the shape drawn after the call begin_fill().\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.end_poly": "Stop recording the vertices of a polygon.\n\nNo argument.\n\nStop recording the vertices of a polygon. Current turtle position is\nlast point of polygon. This will be connected with the first point.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.end_poly()\n", + "Turtle.fillcolor": "Return or set the fillcolor.\n\nArguments:\nFour input formats are allowed:\n - fillcolor()\n Return the current fillcolor as color specification string,\n possibly in tuple format (see example). May be used as\n input to another color/pencolor/fillcolor/bgcolor call.\n - fillcolor(colorstring)\n Set fillcolor to colorstring, which is a Tk color\n specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n - fillcolor((r, g, b))\n Set fillcolor to the RGB color represented by the tuple of\n r, g, and b. Each of r, g, and b must be in the range\n 0..colormode, where colormode is either 1.0 or 255 (see\n colormode()).\n - fillcolor(r, g, b)\n Set fillcolor to the RGB color represented by r, g, and b.\n Each of r, g, and b must be in the range 0..colormode.\n\nIf turtleshape is a polygon, the interior of that polygon is drawn\nwith the newly set fillcolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.fillcolor('violet')\n>>> turtle.fillcolor()\n'violet'\n>>> colormode(255)\n>>> turtle.fillcolor('#ffffff')\n>>> turtle.fillcolor()\n(255.0, 255.0, 255.0)\n", + "Turtle.filling": "Return fillstate (True if filling, False else).\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_fill()\n>>> if turtle.filling():\n... turtle.pensize(5)\n... else:\n... turtle.pensize(3)\n", + "Turtle.forward": "Move the turtle forward by the specified distance.\n\nAliases: forward | fd\n\nArgument:\ndistance -- a number (integer or float)\n\nMove the turtle forward by the specified distance, in the direction\nthe turtle is headed.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.forward(25)\n>>> turtle.position()\n(25.00,0.00)\n>>> turtle.forward(-75)\n>>> turtle.position()\n(-50.00,0.00)\n", + "Turtle.get_poly": "Return the lastly recorded polygon.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> p = turtle.get_poly()\n>>> turtle.register_shape(\"myFavouriteShape\", p)\n", + "Turtle.get_shapepoly": "Return the current shape polygon as tuple of coordinate pairs.\n\nNo argument.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapetransform(4, -1, 0, 2)\n>>> turtle.get_shapepoly()\n((50, -20), (30, 20), (-50, 20), (-30, -20))\n\n", + "Turtle.getpen": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.getscreen": "Return the TurtleScreen object, the turtle is drawing on.\n\nNo argument.\n\nReturn the TurtleScreen object, the turtle is drawing on.\nSo TurtleScreen-methods can be called for that object.\n\nExample (for a Turtle instance named turtle):\n>>> ts = turtle.getscreen()\n>>> ts\n\n>>> ts.bgcolor(\"pink\")\n", + "Turtle.getturtle": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.goto": "Move turtle to an absolute position.\n\nAliases: setpos | setposition | goto:\n\nArguments:\nx -- a number or a pair/vector of numbers\ny -- a number None\n\ncall: goto(x, y) # two coordinates\n--or: goto((x, y)) # a pair (tuple) of coordinates\n--or: goto(vec) # e.g. as returned by pos()\n\nMove turtle to an absolute position. If the pen is down,\na line will be drawn. The turtle's orientation does not change.\n\nExample (for a Turtle instance named turtle):\n>>> tp = turtle.pos()\n>>> tp\n(0.00,0.00)\n>>> turtle.setpos(60,30)\n>>> turtle.pos()\n(60.00,30.00)\n>>> turtle.setpos((20,80))\n>>> turtle.pos()\n(20.00,80.00)\n>>> turtle.setpos(tp)\n>>> turtle.pos()\n(0.00,0.00)\n", + "Turtle.heading": "Return the turtle's current heading.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(67)\n>>> turtle.heading()\n67.0\n", + "Turtle.hideturtle": "Makes the turtle invisible.\n\nAliases: hideturtle | ht\n\nNo argument.\n\nIt's a good idea to do this while you're in the\nmiddle of a complicated drawing, because hiding\nthe turtle speeds up the drawing observably.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n", + "Turtle.home": "Move turtle to the origin - coordinates (0,0).\n\nNo arguments.\n\nMove turtle to the origin - coordinates (0,0) and set its\nheading to its start-orientation (which depends on mode).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.home()\n", + "Turtle.isdown": "Return True if pen is down, False if it's up.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n>>> turtle.isdown()\nFalse\n>>> turtle.pendown()\n>>> turtle.isdown()\nTrue\n", + "Turtle.isvisible": "Return True if the Turtle is shown, False if it's hidden.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> print(turtle.isvisible())\nFalse\n", + "Turtle.left": "Turn turtle left by angle units.\n\nAliases: left | lt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle left by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.left(45)\n>>> turtle.heading()\n67.0\n", + "Turtle.onclick": "Bind fun to mouse-click event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\nadd -- True or False. If True, new binding will be added, otherwise\n it will replace a former binding.\n\nExample for the anonymous turtle, i. e. the procedural way:\n\n>>> def turn(x, y):\n... left(360)\n...\n>>> onclick(turn) # Now clicking into the turtle will turn it.\n>>> onclick(None) # event-binding will be removed\n", + "Turtle.ondrag": "Bind fun to mouse-move event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nEvery sequence of mouse-move-events on a turtle is preceded by a\nmouse-click event on that turtle.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.ondrag(turtle.goto)\n\nSubsequently clicking and dragging a Turtle will move it\nacross the screen thereby producing handdrawings (if pen is\ndown).\n", + "Turtle.onrelease": "Bind fun to mouse-button-release event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nExample (for a MyTurtle instance named joe):\n>>> class MyTurtle(Turtle):\n... def glow(self,x,y):\n... self.fillcolor(\"red\")\n... def unglow(self,x,y):\n... self.fillcolor(\"\")\n...\n>>> joe = MyTurtle()\n>>> joe.onclick(joe.glow)\n>>> joe.onrelease(joe.unglow)\n\nClicking on joe turns fillcolor red, unclicking turns it to\ntransparent.\n", + "Turtle.pen": "Return or set the pen's attributes.\n\nArguments:\n pen -- a dictionary with some or all of the below listed keys.\n **pendict -- one or more keyword-arguments with the below\n listed keys as keywords.\n\nReturn or set the pen's attributes in a 'pen-dictionary'\nwith the following key/value pairs:\n \"shown\" : True/False\n \"pendown\" : True/False\n \"pencolor\" : color-string or color-tuple\n \"fillcolor\" : color-string or color-tuple\n \"pensize\" : positive number\n \"speed\" : number in range 0..10\n \"resizemode\" : \"auto\" or \"user\" or \"noresize\"\n \"stretchfactor\": (positive number, positive number)\n \"shearfactor\": number\n \"outline\" : positive number\n \"tilt\" : number\n\nThis dictionary can be used as argument for a subsequent\npen()-call to restore the former pen-state. Moreover one\nor more of these attributes can be provided as keyword-arguments.\nThis can be used to set several pen attributes in one statement.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.pen(fillcolor=\"black\", pencolor=\"red\", pensize=10)\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> penstate=turtle.pen()\n>>> turtle.color(\"yellow\",\"\")\n>>> turtle.penup()\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> p.pen(penstate, fillcolor=\"green\")\n>>> p.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n", + "Turtle.pencolor": "Return or set the pencolor.\n\nArguments:\nFour input formats are allowed:\n - pencolor()\n Return the current pencolor as color specification string or\n as a tuple (see example). May be used as input to another\n color/pencolor/fillcolor/bgcolor call.\n - pencolor(colorstring)\n Set pencolor to colorstring, which is a Tk color\n specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n - pencolor((r, g, b))\n Set pencolor to the RGB color represented by the tuple of\n r, g, and b. Each of r, g, and b must be in the range\n 0..colormode, where colormode is either 1.0 or 255 (see\n colormode()).\n - pencolor(r, g, b)\n Set pencolor to the RGB color represented by r, g, and b.\n Each of r, g, and b must be in the range 0..colormode.\n\nIf turtleshape is a polygon, the outline of that polygon is drawn\nwith the newly set pencolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pencolor('brown')\n>>> turtle.pencolor()\n'brown'\n>>> colormode(255)\n>>> turtle.pencolor('#32c18f')\n>>> turtle.pencolor()\n(50.0, 193.0, 143.0)\n", + "Turtle.pendown": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.pensize": "Set or return the line thickness.\n\nAliases: pensize | width\n\nArgument:\nwidth -- positive number\n\nSet the line thickness to width or return it. If resizemode is set\nto \"auto\" and turtleshape is a polygon, that polygon is drawn with\nthe same line thickness. If no argument is given, current pensize\nis returned.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pensize()\n1\n>>> turtle.pensize(10) # from here on lines of width 10 are drawn\n", + "Turtle.penup": "Pull the pen up -- no drawing when moving.\n\nAliases: penup | pu | up\n\nNo argument\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n", + "Turtle.position": "Return the turtle's current location (x,y), as a Vec2D-vector.\n\nAliases: pos | position\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00, 240.00)\n", + "Turtle.radians": "Set the angle measurement units to radians.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n90\n>>> turtle.radians()\n>>> turtle.heading()\n1.5707963267948966\n", + "Turtle.reset": "Delete the turtle's drawings and restore its default values.\n\nNo argument.\n\nDelete the turtle's drawings from the screen, re-center the turtle\nand set variables to the default values.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,-22.00)\n>>> turtle.heading()\n100.0\n>>> turtle.reset()\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.heading()\n0.0\n", + "Turtle.resizemode": "Set resizemode to one of the values: \"auto\", \"user\", \"noresize\".\n\n(Optional) Argument:\nrmode -- one of the strings \"auto\", \"user\", \"noresize\"\n\nDifferent resizemodes have the following effects:\n - \"auto\" adapts the appearance of the turtle\n corresponding to the value of pensize.\n - \"user\" adapts the appearance of the turtle according to the\n values of stretchfactor and outlinewidth (outline),\n which are set by shapesize()\n - \"noresize\" no adaption of the turtle's appearance takes place.\nIf no argument is given, return current resizemode.\nresizemode(\"user\") is called by a call of shapesize with arguments.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"noresize\")\n>>> turtle.resizemode()\n'noresize'\n", + "Turtle.right": "Turn turtle right by angle units.\n\nAliases: right | rt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle right by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.right(45)\n>>> turtle.heading()\n337.0\n", + "Turtle.setheading": "Set the orientation of the turtle to to_angle.\n\nAliases: setheading | seth\n\nArgument:\nto_angle -- a number (integer or float)\n\nSet the orientation of the turtle to to_angle.\nHere are some common directions in degrees:\n\n standard - mode: logo-mode:\n-------------------|--------------------\n 0 - east 0 - north\n 90 - north 90 - east\n 180 - west 180 - south\n 270 - south 270 - west\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setheading(90)\n>>> turtle.heading()\n90\n", + "Turtle.setundobuffer": "Set or disable undobuffer.\n\nArgument:\nsize -- an integer or None\n\nIf size is an integer an empty undobuffer of given size is installed.\nSize gives the maximum number of turtle-actions that can be undone\nby the undo() function.\nIf size is None, no undobuffer is present.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setundobuffer(42)\n", + "Turtle.setx": "Set the turtle's first coordinate to x\n\nArgument:\nx -- a number (integer or float)\n\nSet the turtle's first coordinate to x, leave second coordinate\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 240.00)\n>>> turtle.setx(10)\n>>> turtle.position()\n(10.00, 240.00)\n", + "Turtle.sety": "Set the turtle's second coordinate to y\n\nArgument:\ny -- a number (integer or float)\n\nSet the turtle's first coordinate to x, second coordinate remains\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 40.00)\n>>> turtle.sety(-10)\n>>> turtle.position()\n(0.00, -10.00)\n", + "Turtle.shape": "Set turtle shape to shape with given name / return current shapename.\n\nOptional argument:\nname -- a string, which is a valid shapename\n\nSet turtle shape to shape with given name or, if name is not given,\nreturn name of current shape.\nShape with name must exist in the TurtleScreen's shape dictionary.\nInitially there are the following polygon shapes:\n'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'.\nTo learn about how to deal with shapes see Screen-method register_shape.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.shape()\n'arrow'\n>>> turtle.shape(\"turtle\")\n>>> turtle.shape()\n'turtle'\n", + "Turtle.shapesize": "Set/return turtle's stretchfactors/outline. Set resizemode to \"user\".\n\nOptional arguments:\n stretch_wid : positive number\n stretch_len : positive number\n outline : positive number\n\nReturn or set the pen's attributes x/y-stretchfactors and/or outline.\nSet resizemode to \"user\".\nIf and only if resizemode is set to \"user\", the turtle will be displayed\nstretched according to its stretchfactors:\nstretch_wid is stretchfactor perpendicular to orientation\nstretch_len is stretchfactor in direction of turtles orientation.\noutline determines the width of the shapes's outline.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"user\")\n>>> turtle.shapesize(5, 5, 12)\n>>> turtle.shapesize(outline=8)\n", + "Turtle.shapetransform": "Set or return the current transformation matrix of the turtle shape.\n\nOptional arguments: t11, t12, t21, t22 -- numbers.\n\nIf none of the matrix elements are given, return the transformation\nmatrix.\nOtherwise set the given elements and transform the turtleshape\naccording to the matrix consisting of first row t11, t12 and\nsecond row t21, 22.\nModify stretchfactor, shearfactor and tiltangle according to the\ngiven matrix.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapesize(4,2)\n>>> turtle.shearfactor(-0.5)\n>>> turtle.shapetransform()\n(4.0, -1.0, -0.0, 2.0)\n", + "Turtle.shearfactor": "Set or return the current shearfactor.\n\nOptional argument: shear -- number, tangent of the shear angle\n\nShear the turtleshape according to the given shearfactor shear,\nwhich is the tangent of the shear angle. DO NOT change the\nturtle's heading (direction of movement).\nIf shear is not given: return the current shearfactor, i. e. the\ntangent of the shear angle, by which lines parallel to the\nheading of the turtle are sheared.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.shearfactor(0.5)\n>>> turtle.shearfactor()\n>>> 0.5\n", + "Turtle.showturtle": "Makes the turtle visible.\n\nAliases: showturtle | st\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> turtle.showturtle()\n", + "Turtle.speed": "Return or set the turtle's speed.\n\nOptional argument:\nspeed -- an integer in the range 0..10 or a speedstring (see below)\n\nSet the turtle's speed to an integer value in the range 0 .. 10.\nIf no argument is given: return current speed.\n\nIf input is a number greater than 10 or smaller than 0.5,\nspeed is set to 0.\nSpeedstrings are mapped to speedvalues in the following way:\n 'fastest' : 0\n 'fast' : 10\n 'normal' : 6\n 'slow' : 3\n 'slowest' : 1\nspeeds from 1 to 10 enforce increasingly faster animation of\nline drawing and turtle turning.\n\nAttention:\nspeed = 0 : *no* animation takes place. forward/back makes turtle jump\nand likewise left/right make the turtle turn instantly.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.speed(3)\n", + "Turtle.stamp": "Stamp a copy of the turtleshape onto the canvas and return its id.\n\nNo argument.\n\nStamp a copy of the turtle shape onto the canvas at the current\nturtle position. Return a stamp_id for that stamp, which can be\nused to delete it by calling clearstamp(stamp_id).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> turtle.stamp()\n13\n>>> turtle.fd(50)\n", + "Turtle.teleport": "Instantly move turtle to an absolute position.\n\nArguments:\nx -- a number or None\ny -- a number None\nfill_gap -- a boolean This argument must be specified by name.\n\ncall: teleport(x, y) # two coordinates\n--or: teleport(x) # teleport to x position, keeping y as is\n--or: teleport(y=y) # teleport to y position, keeping x as is\n--or: teleport(x, y, fill_gap=True)\n # teleport but fill the gap in between\n\nMove turtle to an absolute position. Unlike goto(x, y), a line will not\nbe drawn. The turtle's orientation does not change. If currently\nfilling, the polygon(s) teleported from will be filled after leaving,\nand filling will begin again after teleporting. This can be disabled\nwith fill_gap=True, which makes the imaginary line traveled during\nteleporting act as a fill barrier like in goto(x, y).\n\nExample (for a Turtle instance named turtle):\n>>> tp = turtle.pos()\n>>> tp\n(0.00,0.00)\n>>> turtle.teleport(60)\n>>> turtle.pos()\n(60.00,0.00)\n>>> turtle.teleport(y=10)\n>>> turtle.pos()\n(60.00,10.00)\n>>> turtle.teleport(20, 30)\n>>> turtle.pos()\n(20.00,30.00)\n", + "Turtle.tilt": "Rotate the turtleshape by angle.\n\nArgument:\nangle - a number\n\nRotate the turtleshape by angle from its current tilt-angle,\nbut do NOT change the turtle's heading (direction of movement).\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n", + "Turtle.tiltangle": "Set or return the current tilt-angle.\n\nOptional argument: angle -- number\n\nRotate the turtleshape to point in the direction specified by angle,\nregardless of its current tilt-angle. DO NOT change the turtle's\nheading (direction of movement).\nIf angle is not given: return the current tilt-angle, i. e. the angle\nbetween the orientation of the turtleshape and the heading of the\nturtle (its direction of movement).\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5, 2)\n>>> turtle.tiltangle()\n0.0\n>>> turtle.tiltangle(45)\n>>> turtle.tiltangle()\n45.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.tiltangle(-45)\n>>> turtle.tiltangle()\n315.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n", + "Turtle.towards": "Return the angle of the line from the turtle's position to (x, y).\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nReturn the angle, between the line from turtle-position to position\nspecified by x, y and the turtle's start orientation. (Depends on\nmodes - \"standard\" or \"logo\")\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(10.00, 10.00)\n>>> turtle.towards(0,0)\n225.0\n", + "Turtle.undo": "undo (repeatedly) the last turtle action.\n\nNo argument.\n\nundo (repeatedly) the last turtle action.\nNumber of available undo actions is determined by the size of\nthe undobuffer.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(4):\n... turtle.fd(50); turtle.lt(80)\n...\n>>> for i in range(8):\n... turtle.undo()\n...\n", + "Turtle.undobufferentries": "Return count of entries in the undobuffer.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> while undobufferentries():\n... undo()\n", + "Turtle.write": "Write text at the current turtle position.\n\nArguments:\narg -- info, which is to be written to the TurtleScreen\nmove (optional) -- True/False\nalign (optional) -- one of the strings \"left\", \"center\" or right\"\nfont (optional) -- a triple (fontname, fontsize, fonttype)\n\nWrite text - the string representation of arg - at the current\nturtle position according to align (\"left\", \"center\" or right\")\nand with the given font.\nIf move is True, the pen is moved to the bottom-right corner\nof the text. By default, move is False.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.write('Home = ', True, align=\"center\")\n>>> turtle.write((0,0), True)\n", + "Turtle.xcor": "Return the turtle's x coordinate.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print(turtle.xcor())\n50.0\n", + "Turtle.ycor": "Return the turtle's y coordinate\n---\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print(turtle.ycor())\n86.6025403784\n", + "TurtleScreen": "Provides screen oriented methods like bgcolor etc.\n\nOnly relies upon the methods of TurtleScreenBase and NOT\nupon components of the underlying graphics toolkit -\nwhich is Tkinter in this case.\n", + "Vec2D": "A 2 dimensional vector class, used as a helper class\nfor implementing turtle graphics.\nMay be useful for turtle graphics programs also.\nDerived from tuple, so a vector is a tuple!\n\nProvides (for a, b vectors, k number):\n a+b vector addition\n a-b vector subtraction\n a*b inner product\n k*a and a*k multiplication with scalar\n |a| absolute value of a\n a.rotate(angle) rotation\n", + "_Screen.bgcolor": "Set or return backgroundcolor of the TurtleScreen.\n\nFour input formats are allowed:\n - bgcolor()\n Return the current background color as color specification\n string or as a tuple (see example). May be used as input\n to another color/pencolor/fillcolor/bgcolor call.\n - bgcolor(colorstring)\n Set the background color to colorstring, which is a Tk color\n specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n - bgcolor((r, g, b))\n Set the background color to the RGB color represented by\n the tuple of r, g, and b. Each of r, g, and b must be in\n the range 0..colormode, where colormode is either 1.0 or 255\n (see colormode()).\n - bgcolor(r, g, b)\n Set the background color to the RGB color represented by\n r, g, and b. Each of r, g, and b must be in the range\n 0..colormode.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgcolor(\"orange\")\n>>> screen.bgcolor()\n'orange'\n>>> colormode(255)\n>>> screen.bgcolor('#800080')\n>>> screen.bgcolor()\n(128.0, 0.0, 128.0)\n", + "_Screen.bgpic": "Set background image or return name of current backgroundimage.\n\nOptional argument:\npicname -- a string, name of a gif-file or \"nopic\".\n\nIf picname is a filename, set the corresponding image as background.\nIf picname is \"nopic\", delete backgroundimage, if present.\nIf picname is None, return the filename of the current backgroundimage.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgpic()\n'nopic'\n>>> screen.bgpic(\"landscape.gif\")\n>>> screen.bgpic()\n'landscape.gif'\n", + "_Screen.bye": "Shut the turtlegraphics window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bye()\n", + "_Screen.clearscreen": "Delete all drawings and all turtles from the TurtleScreen.\n\nNo argument.\n\nReset empty TurtleScreen to its initial state: white background,\nno backgroundimage, no eventbindings and tracing on.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.clear()\n\nNote: this method is not available as function.\n", + "_Screen.colormode": "Return the colormode or set it to 1.0 or 255.\n\nOptional argument:\ncmode -- one of the values 1.0 or 255\n\nr, g, b values of colortriples have to be in range 0..cmode.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.colormode()\n1.0\n>>> screen.colormode(255)\n>>> pencolor(240,160,80)\n", + "_Screen.delay": "Return or set the drawing delay in milliseconds.\n\nOptional argument:\ndelay -- positive integer\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.delay(15)\n>>> screen.delay()\n15\n", + "_Screen.exitonclick": "Go into mainloop until the mouse is clicked.\n\nNo arguments.\n\nBind bye() method to mouseclick on TurtleScreen.\nIf \"using_IDLE\" - value in configuration dictionary is False\n(default value), enter mainloop.\nIf IDLE with -n switch (no subprocess) is used, this value should be\nset to True in turtle.cfg. In this case IDLE's mainloop\nis active also for the client script.\n\nThis is a method of the Screen-class and not available for\nTurtleScreen instances.\n\nExample (for a Screen instance named screen):\n>>> screen.exitonclick()\n\n", + "_Screen.getcanvas": "Return the Canvas of this TurtleScreen.\n\nNo argument.\n\nExample (for a Screen instance named screen):\n>>> cv = screen.getcanvas()\n>>> cv\n\n", + "_Screen.getshapes": "Return a list of names of all currently available turtle shapes.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.getshapes()\n['arrow', 'blank', 'circle', ... , 'turtle']\n", + "_Screen.listen": "Set focus on TurtleScreen (in order to collect key-events)\n\nNo arguments.\nDummy arguments are provided in order\nto be able to pass listen to the onclick method.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.listen()\n", + "_Screen.mainloop": "Starts event loop - calling Tkinter's mainloop function.\n\nNo argument.\n\nMust be last statement in a turtle graphics program.\nMust NOT be used if a script is run from within IDLE in -n mode\n(No subprocess) - for interactive use of turtle graphics.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.mainloop()\n\n", + "_Screen.mode": "Set turtle-mode ('standard', 'logo' or 'world') and perform reset.\n\nOptional argument:\nmode -- one of the strings 'standard', 'logo' or 'world'\n\nMode 'standard' is compatible with turtle.py.\nMode 'logo' is compatible with most Logo-Turtle-Graphics.\nMode 'world' uses userdefined 'worldcoordinates'. *Attention*: in\nthis mode angles appear distorted if x/y unit-ratio doesn't equal 1.\nIf mode is not given, return the current mode.\n\n Mode Initial turtle heading positive angles\n ------------|-------------------------|-------------------\n 'standard' to the right (east) counterclockwise\n 'logo' upward (north) clockwise\n\nExamples:\n>>> mode('logo') # resets turtle heading to north\n>>> mode()\n'logo'\n", + "_Screen.numinput": "Pop up a dialog window for input of a number.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what numerical information to input.\ndefault: default value\nminval: minimum value for input\nmaxval: maximum value for input\n\nThe number input must be in the range minval .. maxval if these are\ngiven. If not, a hint is issued and the dialog remains open for\ncorrection. Return the number input.\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.numinput(\"Poker\", \"Your stakes:\", 1000, minval=10, maxval=10000)\n\n", + "_Screen.onkey": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onkeypress": "Bind fun to key-press event of key if key is given,\nor to any key-press-event if no key is given.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen\nand a Turtle instance named turtle):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkeypress(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, or by keeping pressed the up-arrow key.\nconsequently drawing a hexagon.\n", + "_Screen.onkeyrelease": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onscreenclick": "Bind fun to mouse-click event on canvas.\n\nArguments:\nfun -- a function with two arguments, the coordinates of the\n clicked point on the canvas.\nbtn -- the number of the mouse-button, defaults to 1\n\nExample (for a TurtleScreen instance named screen)\n\n>>> screen.onclick(goto)\n>>> # Subsequently clicking into the TurtleScreen will\n>>> # make the turtle move to the clicked point.\n>>> screen.onclick(None)\n", + "_Screen.ontimer": "Install a timer, which calls fun after t milliseconds.\n\nArguments:\nfun -- a function with no arguments.\nt -- a number >= 0\n\nExample (for a TurtleScreen instance named screen):\n\n>>> running = True\n>>> def f():\n... if running:\n... fd(50)\n... lt(60)\n... screen.ontimer(f, 250)\n...\n>>> f() # makes the turtle marching around\n>>> running = False\n", + "_Screen.register_shape": "Adds a turtle shape to TurtleScreen's shapelist.\n\nArguments:\n(1) name is the name of a gif-file and shape is None.\n Installs the corresponding image shape.\n !! Image-shapes DO NOT rotate when turning the turtle,\n !! so they do not display the heading of the turtle!\n(2) name is an arbitrary string and shape is a tuple\n of pairs of coordinates. Installs the corresponding\n polygon shape\n(3) name is an arbitrary string and shape is a\n (compound) Shape object. Installs the corresponding\n compound shape.\nTo use a shape, you have to issue the command shape(shapename).\n\ncall: register_shape(\"turtle.gif\")\n--or: register_shape(\"tri\", ((0,0), (10,10), (-10,10)))\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.register_shape(\"triangle\", ((5,-3),(0,5),(-5,-3)))\n\n", + "_Screen.resetscreen": "Reset all Turtles on the Screen to their initial state.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.reset()\n", + "_Screen.screensize": "Resize the canvas the turtles are drawing on.\n\nOptional arguments:\ncanvwidth -- positive integer, new width of canvas in pixels\ncanvheight -- positive integer, new height of canvas in pixels\nbg -- colorstring or color-tuple, new backgroundcolor\nIf no arguments are given, return current (canvaswidth, canvasheight)\n\nDo not alter the drawing window. To observe hidden parts of\nthe canvas use the scrollbars. (Can make visible those parts\nof a drawing, which were outside the canvas before!)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.screensize(2000,1500)\n>>> # e.g. to search for an erroneously escaped turtle ;-)\n", + "_Screen.setup": "Set the size and position of the main window.\n\nArguments:\nwidth: as integer a size in pixels, as float a fraction of the screen.\n Default is 50% of screen.\nheight: as integer the height in pixels, as float a fraction of the\n screen. Default is 75% of screen.\nstartx: if positive, starting position in pixels from the left\n edge of the screen, if negative from the right edge\n Default, startx=None is to center window horizontally.\nstarty: if positive, starting position in pixels from the top\n edge of the screen, if negative from the bottom edge\n Default, starty=None is to center window vertically.\n\nExamples (for a Screen instance named screen):\n>>> screen.setup (width=200, height=200, startx=0, starty=0)\n\nsets window to 200x200 pixels, in upper left of screen\n\n>>> screen.setup(width=.75, height=0.5, startx=None, starty=None)\n\nsets window to 75% of screen by 50% of screen and centers\n", + "_Screen.setworldcoordinates": "Set up a user defined coordinate-system.\n\nArguments:\nllx -- a number, x-coordinate of lower left corner of canvas\nlly -- a number, y-coordinate of lower left corner of canvas\nurx -- a number, x-coordinate of upper right corner of canvas\nury -- a number, y-coordinate of upper right corner of canvas\n\nSet up user coodinat-system and switch to mode 'world' if necessary.\nThis performs a screen.reset. If mode 'world' is already active,\nall drawings are redrawn according to the new coordinates.\n\nBut ATTENTION: in user-defined coordinatesystems angles may appear\ndistorted. (see Screen.mode())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.setworldcoordinates(-10,-0.5,50,1.5)\n>>> for _ in range(36):\n... left(10)\n... forward(0.5)\n", + "_Screen.textinput": "Pop up a dialog window for input of a string.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what information to input.\n\nReturn the string input\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.textinput(\"NIM\", \"Name of first player:\")\n\n", + "_Screen.title": "Set title of turtle-window\n\nArgument:\ntitlestring -- a string, to appear in the titlebar of the\n turtle graphics window.\n\nThis is a method of Screen-class. Not available for TurtleScreen-\nobjects.\n\nExample (for a Screen instance named screen):\n>>> screen.title(\"Welcome to the turtle-zoo!\")\n", + "_Screen.tracer": "Turns turtle animation on/off and set delay for update drawings.\n\nOptional arguments:\nn -- nonnegative integer\ndelay -- nonnegative integer\n\nIf n is given, only each n-th regular screen update is really performed.\n(Can be used to accelerate the drawing of complex graphics.)\nSecond arguments sets delay value (see RawTurtle.delay())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.tracer(8, 25)\n>>> dist = 2\n>>> for i in range(200):\n... fd(dist)\n... rt(90)\n... dist += 2\n", + "_Screen.turtles": "Return the list of turtles on the screen.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.turtles()\n[]\n", + "_Screen.update": "Perform a TurtleScreen update.\n ", + "_Screen.window_height": "Return the height of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_height()\n480\n", + "_Screen.window_width": "Return the width of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_width()\n640\n", + "write_docstringdict": "Create and write docstring-dictionary to file.\n\nOptional argument:\nfilename -- a string, used as filename\n default value is turtle_docstringdict\n\nHas to be called explicitly, (not used by the turtle-graphics classes)\nThe docstring dictionary will be written to the Python script .py\nIt is intended to serve as a template for translation of the docstrings\ninto different languages.\n" + }, + "3.14": { + "RawTurtle": "Animation part of the RawTurtle.\nPuts RawTurtle upon a TurtleScreen and provides tools for\nits animation.\n", + "Screen": "Return the singleton screen object.\nIf none exists at the moment, create a new one and return it,\nelse return the existing one.", + "ScrolledCanvas": "Modeled after the scrolled canvas class from Grayons's Tkinter book.\n\nUsed as the default canvas, which pops up automatically when\nusing turtle graphics functions or the Turtle class.\n", + "Shape": "Data structure modeling shapes.\n\nattribute _type is one of \"polygon\", \"image\", \"compound\"\nattribute _data is - depending on _type a poygon-tuple,\nan image or a list constructed using the addcomponent method.\n", + "Terminator": "Will be raised in TurtleScreen.update, if _RUNNING becomes False.\n\nThis stops execution of a turtle graphics script.\nMain purpose: use in the Demo-Viewer turtle.Demo.py.\n", + "Turtle": "RawTurtle auto-creating (scrolled) canvas.\n\nWhen a Turtle object is created or a function derived from some\nTurtle method is called a TurtleScreen object is automatically created.\n", + "Turtle.back": "Move the turtle backward by distance.\n\nAliases: back | backward | bk\n\nArgument:\ndistance -- a number\n\nMove the turtle backward by distance, opposite to the direction the\nturtle is headed. Do not change the turtle's heading.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.backward(30)\n>>> turtle.position()\n(-30.00,0.00)\n", + "Turtle.begin_fill": "Called just before drawing a shape to be filled.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.begin_poly": "Start recording the vertices of a polygon.\n\nNo argument.\n\nStart recording the vertices of a polygon. Current turtle position\nis first point of polygon.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_poly()\n", + "Turtle.circle": "Draw a circle with given radius.\n\nArguments:\nradius -- a number\nextent (optional) -- a number\nsteps (optional) -- an integer\n\nDraw a circle with given radius. The center is radius units left\nof the turtle; extent - an angle - determines which part of the\ncircle is drawn. If extent is not given, draw the entire circle.\nIf extent is not a full circle, one endpoint of the arc is the\ncurrent pen position. Draw the arc in counterclockwise direction\nif radius is positive, otherwise in clockwise direction. Finally\nthe direction of the turtle is changed by the amount of extent.\n\nAs the circle is approximated by an inscribed regular polygon,\nsteps determines the number of steps to use. If not given,\nit will be calculated automatically. Maybe used to draw regular\npolygons.\n\ncall: circle(radius) # full circle\n--or: circle(radius, extent) # arc\n--or: circle(radius, extent, steps)\n--or: circle(radius, steps=6) # 6-sided polygon\n\nExample (for a Turtle instance named turtle):\n>>> turtle.circle(50)\n>>> turtle.circle(120, 180) # semicircle\n", + "Turtle.clear": "Delete the turtle's drawings from the screen. Do not move turtle.\n\nNo arguments.\n\nDelete the turtle's drawings from the screen. Do not move turtle.\nState and position of the turtle as well as drawings of other\nturtles are not affected.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.clear()\n", + "Turtle.clearstamp": "Delete stamp with given stampid\n\nArgument:\nstampid - an integer, must be return value of previous stamp() call.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> astamp = turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.clearstamp(astamp)\n", + "Turtle.clearstamps": "Delete all or first/last n of turtle's stamps.\n\nOptional argument:\nn -- an integer\n\nIf n is None, delete all of pen's stamps,\nelse if n > 0 delete first n stamps\nelse if n < 0 delete last n stamps.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(8):\n... turtle.stamp(); turtle.fd(30)\n...\n>>> turtle.clearstamps(2)\n>>> turtle.clearstamps(-2)\n>>> turtle.clearstamps()\n", + "Turtle.clone": "Create and return a clone of the turtle.\n\nNo argument.\n\nCreate and return a clone of the turtle with same position, heading\nand turtle properties.\n\nExample (for a Turtle instance named mick):\nmick = Turtle()\njoe = mick.clone()\n", + "Turtle.color": "Return or set the pencolor and fillcolor.\n\nArguments:\nSeveral input formats are allowed.\nThey use 0 to 3 arguments as follows:\n - color()\n Return the current pencolor and the current fillcolor as\n a pair of color specification strings or tuples as returned\n by pencolor() and fillcolor().\n - color(colorstring), color((r,g,b)), color(r,g,b)\n Inputs as in pencolor(), set both, fillcolor and pencolor,\n to the given value.\n - color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2))\n Equivalent to pencolor(colorstring1) and fillcolor(colorstring2)\n and analogously if the other input format is used.\n\nIf turtleshape is a polygon, outline and interior of that polygon\nis drawn with the newly set colors.\nFor more info see: pencolor, fillcolor\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color('red', 'green')\n>>> turtle.color()\n('red', 'green')\n>>> colormode(255)\n>>> color(('#285078', '#a0c8f0'))\n>>> color()\n((40.0, 80.0, 120.0), (160.0, 200.0, 240.0))\n", + "Turtle.degrees": "Set angle measurement units to degrees.\n\nOptional argument:\nfullcircle - a number\n\nSet angle measurement units, i. e. set number\nof 'degrees' for a full circle. Default value is\n360 degrees.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(90)\n>>> turtle.heading()\n90\n\nChange angle measurement unit to grad (also known as gon,\ngrade, or gradian and equals 1/100-th of the right angle.)\n>>> turtle.degrees(400.0)\n>>> turtle.heading()\n100\n\n", + "Turtle.distance": "Return the distance from the turtle to (x,y) in turtle step units.\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00,0.00)\n>>> turtle.distance(30,40)\n50.0\n>>> pen = Turtle()\n>>> pen.forward(77)\n>>> turtle.distance(pen)\n77.0\n", + "Turtle.dot": "Draw a dot with diameter size, using color.\n\nOptional arguments:\nsize -- an integer >= 1 (if given)\ncolor -- a colorstring or a numeric color tuple\n\nDraw a circular dot with diameter size, using color.\nIf size is not given, the maximum of pensize+4 and 2*pensize is used.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.dot()\n>>> turtle.fd(50); turtle.dot(20, \"blue\"); turtle.fd(50)\n", + "Turtle.down": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.end_fill": "Fill the shape drawn after the call begin_fill().\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> turtle.begin_fill()\n>>> turtle.circle(60)\n>>> turtle.end_fill()\n", + "Turtle.end_poly": "Stop recording the vertices of a polygon.\n\nNo argument.\n\nStop recording the vertices of a polygon. Current turtle position is\nlast point of polygon. This will be connected with the first point.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.end_poly()\n", + "Turtle.fill": "A context manager for filling a shape.\n\nImplicitly ensures the code block is wrapped with\nbegin_fill() and end_fill().\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"black\", \"red\")\n>>> with turtle.fill():\n... turtle.circle(60)\n", + "Turtle.fillcolor": "Return or set the fillcolor.\n\nArguments:\nFour input formats are allowed:\n - fillcolor()\n Return the current fillcolor as color specification string,\n possibly in tuple format (see example). May be used as\n input to another color/pencolor/fillcolor/bgcolor call.\n - fillcolor(colorstring)\n Set fillcolor to colorstring, which is a Tk color\n specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n - fillcolor((r, g, b))\n Set fillcolor to the RGB color represented by the tuple of\n r, g, and b. Each of r, g, and b must be in the range\n 0..colormode, where colormode is either 1.0 or 255 (see\n colormode()).\n - fillcolor(r, g, b)\n Set fillcolor to the RGB color represented by r, g, and b.\n Each of r, g, and b must be in the range 0..colormode.\n\nIf turtleshape is a polygon, the interior of that polygon is drawn\nwith the newly set fillcolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.fillcolor('violet')\n>>> turtle.fillcolor()\n'violet'\n>>> colormode(255)\n>>> turtle.fillcolor('#ffffff')\n>>> turtle.fillcolor()\n(255.0, 255.0, 255.0)\n", + "Turtle.filling": "Return fillstate (True if filling, False else).\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.begin_fill()\n>>> if turtle.filling():\n... turtle.pensize(5)\n... else:\n... turtle.pensize(3)\n", + "Turtle.forward": "Move the turtle forward by the specified distance.\n\nAliases: forward | fd\n\nArgument:\ndistance -- a number (integer or float)\n\nMove the turtle forward by the specified distance, in the direction\nthe turtle is headed.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.forward(25)\n>>> turtle.position()\n(25.00,0.00)\n>>> turtle.forward(-75)\n>>> turtle.position()\n(-50.00,0.00)\n", + "Turtle.get_poly": "Return the lastly recorded polygon.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> p = turtle.get_poly()\n>>> turtle.register_shape(\"myFavouriteShape\", p)\n", + "Turtle.get_shapepoly": "Return the current shape polygon as tuple of coordinate pairs.\n\nNo argument.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapetransform(4, -1, 0, 2)\n>>> turtle.get_shapepoly()\n((50, -20), (30, 20), (-50, 20), (-30, -20))\n\n", + "Turtle.getpen": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.getscreen": "Return the TurtleScreen object, the turtle is drawing on.\n\nNo argument.\n\nReturn the TurtleScreen object, the turtle is drawing on.\nSo TurtleScreen-methods can be called for that object.\n\nExample (for a Turtle instance named turtle):\n>>> ts = turtle.getscreen()\n>>> ts\n\n>>> ts.bgcolor(\"pink\")\n", + "Turtle.getturtle": "Return the Turtleobject itself.\n\nNo argument.\n\nOnly reasonable use: as a function to return the 'anonymous turtle':\n\nExample:\n>>> pet = getturtle()\n>>> pet.fd(50)\n>>> pet\n\n>>> turtles()\n[]\n", + "Turtle.goto": "Move turtle to an absolute position.\n\nAliases: setpos | setposition | goto:\n\nArguments:\nx -- a number or a pair/vector of numbers\ny -- a number None\n\ncall: goto(x, y) # two coordinates\n--or: goto((x, y)) # a pair (tuple) of coordinates\n--or: goto(vec) # e.g. as returned by pos()\n\nMove turtle to an absolute position. If the pen is down,\na line will be drawn. The turtle's orientation does not change.\n\nExample (for a Turtle instance named turtle):\n>>> tp = turtle.pos()\n>>> tp\n(0.00,0.00)\n>>> turtle.setpos(60,30)\n>>> turtle.pos()\n(60.00,30.00)\n>>> turtle.setpos((20,80))\n>>> turtle.pos()\n(20.00,80.00)\n>>> turtle.setpos(tp)\n>>> turtle.pos()\n(0.00,0.00)\n", + "Turtle.heading": "Return the turtle's current heading.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.left(67)\n>>> turtle.heading()\n67.0\n", + "Turtle.hideturtle": "Makes the turtle invisible.\n\nAliases: hideturtle | ht\n\nNo argument.\n\nIt's a good idea to do this while you're in the\nmiddle of a complicated drawing, because hiding\nthe turtle speeds up the drawing observably.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n", + "Turtle.home": "Move turtle to the origin - coordinates (0,0).\n\nNo arguments.\n\nMove turtle to the origin - coordinates (0,0) and set its\nheading to its start-orientation (which depends on mode).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.home()\n", + "Turtle.isdown": "Return True if pen is down, False if it's up.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n>>> turtle.isdown()\nFalse\n>>> turtle.pendown()\n>>> turtle.isdown()\nTrue\n", + "Turtle.isvisible": "Return True if the Turtle is shown, False if it's hidden.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> print(turtle.isvisible())\nFalse\n", + "Turtle.left": "Turn turtle left by angle units.\n\nAliases: left | lt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle left by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.left(45)\n>>> turtle.heading()\n67.0\n", + "Turtle.onclick": "Bind fun to mouse-click event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\nadd -- True or False. If True, new binding will be added, otherwise\n it will replace a former binding.\n\nExample for the anonymous turtle, i. e. the procedural way:\n\n>>> def turn(x, y):\n... left(360)\n...\n>>> onclick(turn) # Now clicking into the turtle will turn it.\n>>> onclick(None) # event-binding will be removed\n", + "Turtle.ondrag": "Bind fun to mouse-move event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nEvery sequence of mouse-move-events on a turtle is preceded by a\nmouse-click event on that turtle.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.ondrag(turtle.goto)\n\nSubsequently clicking and dragging a Turtle will move it\nacross the screen thereby producing handdrawings (if pen is\ndown).\n", + "Turtle.onrelease": "Bind fun to mouse-button-release event on this turtle on canvas.\n\nArguments:\nfun -- a function with two arguments, to which will be assigned\n the coordinates of the clicked point on the canvas.\nbtn -- number of the mouse-button defaults to 1 (left mouse button).\n\nExample (for a MyTurtle instance named joe):\n>>> class MyTurtle(Turtle):\n... def glow(self,x,y):\n... self.fillcolor(\"red\")\n... def unglow(self,x,y):\n... self.fillcolor(\"\")\n...\n>>> joe = MyTurtle()\n>>> joe.onclick(joe.glow)\n>>> joe.onrelease(joe.unglow)\n\nClicking on joe turns fillcolor red, unclicking turns it to\ntransparent.\n", + "Turtle.pen": "Return or set the pen's attributes.\n\nArguments:\n pen -- a dictionary with some or all of the below listed keys.\n **pendict -- one or more keyword-arguments with the below\n listed keys as keywords.\n\nReturn or set the pen's attributes in a 'pen-dictionary'\nwith the following key/value pairs:\n \"shown\" : True/False\n \"pendown\" : True/False\n \"pencolor\" : color-string or color-tuple\n \"fillcolor\" : color-string or color-tuple\n \"pensize\" : positive number\n \"speed\" : number in range 0..10\n \"resizemode\" : \"auto\" or \"user\" or \"noresize\"\n \"stretchfactor\": (positive number, positive number)\n \"shearfactor\": number\n \"outline\" : positive number\n \"tilt\" : number\n\nThis dictionary can be used as argument for a subsequent\npen()-call to restore the former pen-state. Moreover one\nor more of these attributes can be provided as keyword-arguments.\nThis can be used to set several pen attributes in one statement.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.pen(fillcolor=\"black\", pencolor=\"red\", pensize=10)\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> penstate=turtle.pen()\n>>> turtle.color(\"yellow\",\"\")\n>>> turtle.penup()\n>>> turtle.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n>>> p.pen(penstate, fillcolor=\"green\")\n>>> p.pen()\n{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,\n'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',\n'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}\n", + "Turtle.pencolor": "Return or set the pencolor.\n\nArguments:\nFour input formats are allowed:\n - pencolor()\n Return the current pencolor as color specification string or\n as a tuple (see example). May be used as input to another\n color/pencolor/fillcolor/bgcolor call.\n - pencolor(colorstring)\n Set pencolor to colorstring, which is a Tk color\n specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n - pencolor((r, g, b))\n Set pencolor to the RGB color represented by the tuple of\n r, g, and b. Each of r, g, and b must be in the range\n 0..colormode, where colormode is either 1.0 or 255 (see\n colormode()).\n - pencolor(r, g, b)\n Set pencolor to the RGB color represented by r, g, and b.\n Each of r, g, and b must be in the range 0..colormode.\n\nIf turtleshape is a polygon, the outline of that polygon is drawn\nwith the newly set pencolor.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pencolor('brown')\n>>> turtle.pencolor()\n'brown'\n>>> colormode(255)\n>>> turtle.pencolor('#32c18f')\n>>> turtle.pencolor()\n(50.0, 193.0, 143.0)\n", + "Turtle.pendown": "Pull the pen down -- drawing when moving.\n\nAliases: pendown | pd | down\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pendown()\n", + "Turtle.pensize": "Set or return the line thickness.\n\nAliases: pensize | width\n\nArgument:\nwidth -- positive number\n\nSet the line thickness to width or return it. If resizemode is set\nto \"auto\" and turtleshape is a polygon, that polygon is drawn with\nthe same line thickness. If no argument is given, current pensize\nis returned.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pensize()\n1\n>>> turtle.pensize(10) # from here on lines of width 10 are drawn\n", + "Turtle.penup": "Pull the pen up -- no drawing when moving.\n\nAliases: penup | pu | up\n\nNo argument\n\nExample (for a Turtle instance named turtle):\n>>> turtle.penup()\n", + "Turtle.poly": "A context manager for recording the vertices of a polygon.\n\nImplicitly ensures that the code block is wrapped with\nbegin_poly() and end_poly()\n\nExample (for a Turtle instance named turtle) where we create a\ntriangle as the polygon and move the turtle 100 steps forward:\n>>> with turtle.poly():\n... for side in range(3)\n... turtle.forward(50)\n... turtle.right(60)\n>>> turtle.forward(100)\n", + "Turtle.position": "Return the turtle's current location (x,y), as a Vec2D-vector.\n\nAliases: pos | position\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(0.00, 240.00)\n", + "Turtle.radians": "Set the angle measurement units to radians.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n90\n>>> turtle.radians()\n>>> turtle.heading()\n1.5707963267948966\n", + "Turtle.reset": "Delete the turtle's drawings and restore its default values.\n\nNo argument.\n\nDelete the turtle's drawings from the screen, re-center the turtle\nand set variables to the default values.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00,-22.00)\n>>> turtle.heading()\n100.0\n>>> turtle.reset()\n>>> turtle.position()\n(0.00,0.00)\n>>> turtle.heading()\n0.0\n", + "Turtle.resizemode": "Set resizemode to one of the values: \"auto\", \"user\", \"noresize\".\n\n(Optional) Argument:\nrmode -- one of the strings \"auto\", \"user\", \"noresize\"\n\nDifferent resizemodes have the following effects:\n - \"auto\" adapts the appearance of the turtle\n corresponding to the value of pensize.\n - \"user\" adapts the appearance of the turtle according to the\n values of stretchfactor and outlinewidth (outline),\n which are set by shapesize()\n - \"noresize\" no adaption of the turtle's appearance takes place.\nIf no argument is given, return current resizemode.\nresizemode(\"user\") is called by a call of shapesize with arguments.\n\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"noresize\")\n>>> turtle.resizemode()\n'noresize'\n", + "Turtle.right": "Turn turtle right by angle units.\n\nAliases: right | rt\n\nArgument:\nangle -- a number (integer or float)\n\nTurn turtle right by angle units. (Units are by default degrees,\nbut can be set via the degrees() and radians() functions.)\nAngle orientation depends on mode. (See this.)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.heading()\n22.0\n>>> turtle.right(45)\n>>> turtle.heading()\n337.0\n", + "Turtle.setheading": "Set the orientation of the turtle to to_angle.\n\nAliases: setheading | seth\n\nArgument:\nto_angle -- a number (integer or float)\n\nSet the orientation of the turtle to to_angle.\nHere are some common directions in degrees:\n\n standard - mode: logo-mode:\n-------------------|--------------------\n 0 - east 0 - north\n 90 - north 90 - east\n 180 - west 180 - south\n 270 - south 270 - west\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setheading(90)\n>>> turtle.heading()\n90\n", + "Turtle.setundobuffer": "Set or disable undobuffer.\n\nArgument:\nsize -- an integer or None\n\nIf size is an integer an empty undobuffer of given size is installed.\nSize gives the maximum number of turtle-actions that can be undone\nby the undo() function.\nIf size is None, no undobuffer is present.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.setundobuffer(42)\n", + "Turtle.setx": "Set the turtle's first coordinate to x\n\nArgument:\nx -- a number (integer or float)\n\nSet the turtle's first coordinate to x, leave second coordinate\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 240.00)\n>>> turtle.setx(10)\n>>> turtle.position()\n(10.00, 240.00)\n", + "Turtle.sety": "Set the turtle's second coordinate to y\n\nArgument:\ny -- a number (integer or float)\n\nSet the turtle's first coordinate to x, second coordinate remains\nunchanged.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.position()\n(0.00, 40.00)\n>>> turtle.sety(-10)\n>>> turtle.position()\n(0.00, -10.00)\n", + "Turtle.shape": "Set turtle shape to shape with given name / return current shapename.\n\nOptional argument:\nname -- a string, which is a valid shapename\n\nSet turtle shape to shape with given name or, if name is not given,\nreturn name of current shape.\nShape with name must exist in the TurtleScreen's shape dictionary.\nInitially there are the following polygon shapes:\n'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'.\nTo learn about how to deal with shapes see Screen-method register_shape.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.shape()\n'arrow'\n>>> turtle.shape(\"turtle\")\n>>> turtle.shape()\n'turtle'\n", + "Turtle.shapesize": "Set/return turtle's stretchfactors/outline. Set resizemode to \"user\".\n\nOptional arguments:\n stretch_wid : positive number\n stretch_len : positive number\n outline : positive number\n\nReturn or set the pen's attributes x/y-stretchfactors and/or outline.\nSet resizemode to \"user\".\nIf and only if resizemode is set to \"user\", the turtle will be displayed\nstretched according to its stretchfactors:\nstretch_wid is stretchfactor perpendicular to orientation\nstretch_len is stretchfactor in direction of turtles orientation.\noutline determines the width of the shapes's outline.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.resizemode(\"user\")\n>>> turtle.shapesize(5, 5, 12)\n>>> turtle.shapesize(outline=8)\n", + "Turtle.shapetransform": "Set or return the current transformation matrix of the turtle shape.\n\nOptional arguments: t11, t12, t21, t22 -- numbers.\n\nIf none of the matrix elements are given, return the transformation\nmatrix.\nOtherwise set the given elements and transform the turtleshape\naccording to the matrix consisting of first row t11, t12 and\nsecond row t21, 22.\nModify stretchfactor, shearfactor and tiltangle according to the\ngiven matrix.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"square\")\n>>> turtle.shapesize(4,2)\n>>> turtle.shearfactor(-0.5)\n>>> turtle.shapetransform()\n(4.0, -1.0, -0.0, 2.0)\n", + "Turtle.shearfactor": "Set or return the current shearfactor.\n\nOptional argument: shear -- number, tangent of the shear angle\n\nShear the turtleshape according to the given shearfactor shear,\nwhich is the tangent of the shear angle. DO NOT change the\nturtle's heading (direction of movement).\nIf shear is not given: return the current shearfactor, i. e. the\ntangent of the shear angle, by which lines parallel to the\nheading of the turtle are sheared.\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.shearfactor(0.5)\n>>> turtle.shearfactor()\n>>> 0.5\n", + "Turtle.showturtle": "Makes the turtle visible.\n\nAliases: showturtle | st\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.hideturtle()\n>>> turtle.showturtle()\n", + "Turtle.speed": "Return or set the turtle's speed.\n\nOptional argument:\nspeed -- an integer in the range 0..10 or a speedstring (see below)\n\nSet the turtle's speed to an integer value in the range 0 .. 10.\nIf no argument is given: return current speed.\n\nIf input is a number greater than 10 or smaller than 0.5,\nspeed is set to 0.\nSpeedstrings are mapped to speedvalues in the following way:\n 'fastest' : 0\n 'fast' : 10\n 'normal' : 6\n 'slow' : 3\n 'slowest' : 1\nspeeds from 1 to 10 enforce increasingly faster animation of\nline drawing and turtle turning.\n\nAttention:\nspeed = 0 : *no* animation takes place. forward/back makes turtle jump\nand likewise left/right make the turtle turn instantly.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.speed(3)\n", + "Turtle.stamp": "Stamp a copy of the turtleshape onto the canvas and return its id.\n\nNo argument.\n\nStamp a copy of the turtle shape onto the canvas at the current\nturtle position. Return a stamp_id for that stamp, which can be\nused to delete it by calling clearstamp(stamp_id).\n\nExample (for a Turtle instance named turtle):\n>>> turtle.color(\"blue\")\n>>> turtle.stamp()\n13\n>>> turtle.fd(50)\n", + "Turtle.teleport": "Instantly move turtle to an absolute position.\n\nArguments:\nx -- a number or None\ny -- a number None\nfill_gap -- a boolean This argument must be specified by name.\n\ncall: teleport(x, y) # two coordinates\n--or: teleport(x) # teleport to x position, keeping y as is\n--or: teleport(y=y) # teleport to y position, keeping x as is\n--or: teleport(x, y, fill_gap=True)\n # teleport but fill the gap in between\n\nMove turtle to an absolute position. Unlike goto(x, y), a line will not\nbe drawn. The turtle's orientation does not change. If currently\nfilling, the polygon(s) teleported from will be filled after leaving,\nand filling will begin again after teleporting. This can be disabled\nwith fill_gap=True, which makes the imaginary line traveled during\nteleporting act as a fill barrier like in goto(x, y).\n\nExample (for a Turtle instance named turtle):\n>>> tp = turtle.pos()\n>>> tp\n(0.00,0.00)\n>>> turtle.teleport(60)\n>>> turtle.pos()\n(60.00,0.00)\n>>> turtle.teleport(y=10)\n>>> turtle.pos()\n(60.00,10.00)\n>>> turtle.teleport(20, 30)\n>>> turtle.pos()\n(20.00,30.00)\n", + "Turtle.tilt": "Rotate the turtleshape by angle.\n\nArgument:\nangle - a number\n\nRotate the turtleshape by angle from its current tilt-angle,\nbut do NOT change the turtle's heading (direction of movement).\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5,2)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n>>> turtle.tilt(30)\n>>> turtle.fd(50)\n", + "Turtle.tiltangle": "Set or return the current tilt-angle.\n\nOptional argument: angle -- number\n\nRotate the turtleshape to point in the direction specified by angle,\nregardless of its current tilt-angle. DO NOT change the turtle's\nheading (direction of movement).\nIf angle is not given: return the current tilt-angle, i. e. the angle\nbetween the orientation of the turtleshape and the heading of the\nturtle (its direction of movement).\n\nExamples (for a Turtle instance named turtle):\n>>> turtle.shape(\"circle\")\n>>> turtle.shapesize(5, 2)\n>>> turtle.tiltangle()\n0.0\n>>> turtle.tiltangle(45)\n>>> turtle.tiltangle()\n45.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n>>> turtle.tiltangle(-45)\n>>> turtle.tiltangle()\n315.0\n>>> turtle.stamp()\n>>> turtle.fd(50)\n", + "Turtle.towards": "Return the angle of the line from the turtle's position to (x, y).\n\nArguments:\nx -- a number or a pair/vector of numbers or a turtle instance\ny -- a number None None\n\ncall: distance(x, y) # two coordinates\n--or: distance((x, y)) # a pair (tuple) of coordinates\n--or: distance(vec) # e.g. as returned by pos()\n--or: distance(mypen) # where mypen is another turtle\n\nReturn the angle, between the line from turtle-position to position\nspecified by x, y and the turtle's start orientation. (Depends on\nmodes - \"standard\" or \"logo\")\n\nExample (for a Turtle instance named turtle):\n>>> turtle.pos()\n(10.00, 10.00)\n>>> turtle.towards(0,0)\n225.0\n", + "Turtle.undo": "undo (repeatedly) the last turtle action.\n\nNo argument.\n\nundo (repeatedly) the last turtle action.\nNumber of available undo actions is determined by the size of\nthe undobuffer.\n\nExample (for a Turtle instance named turtle):\n>>> for i in range(4):\n... turtle.fd(50); turtle.lt(80)\n...\n>>> for i in range(8):\n... turtle.undo()\n...\n", + "Turtle.undobufferentries": "Return count of entries in the undobuffer.\n\nNo argument.\n\nExample (for a Turtle instance named turtle):\n>>> while undobufferentries():\n... undo()\n", + "Turtle.write": "Write text at the current turtle position.\n\nArguments:\narg -- info, which is to be written to the TurtleScreen\nmove (optional) -- True/False\nalign (optional) -- one of the strings \"left\", \"center\" or right\"\nfont (optional) -- a triple (fontname, fontsize, fonttype)\n\nWrite text - the string representation of arg - at the current\nturtle position according to align (\"left\", \"center\" or right\")\nand with the given font.\nIf move is True, the pen is moved to the bottom-right corner\nof the text. By default, move is False.\n\nExample (for a Turtle instance named turtle):\n>>> turtle.write('Home = ', True, align=\"center\")\n>>> turtle.write((0,0), True)\n", + "Turtle.xcor": "Return the turtle's x coordinate.\n\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print(turtle.xcor())\n50.0\n", + "Turtle.ycor": "Return the turtle's y coordinate\n---\nNo arguments.\n\nExample (for a Turtle instance named turtle):\n>>> reset()\n>>> turtle.left(60)\n>>> turtle.forward(100)\n>>> print(turtle.ycor())\n86.6025403784\n", + "TurtleScreen": "Provides screen oriented methods like bgcolor etc.\n\nOnly relies upon the methods of TurtleScreenBase and NOT\nupon components of the underlying graphics toolkit -\nwhich is Tkinter in this case.\n", + "Vec2D": "A 2 dimensional vector class, used as a helper class\nfor implementing turtle graphics.\nMay be useful for turtle graphics programs also.\nDerived from tuple, so a vector is a tuple!\n\nProvides (for a, b vectors, k number):\n a+b vector addition\n a-b vector subtraction\n a*b inner product\n k*a and a*k multiplication with scalar\n |a| absolute value of a\n a.rotate(angle) rotation\n", + "_Screen.bgcolor": "Set or return backgroundcolor of the TurtleScreen.\n\nFour input formats are allowed:\n - bgcolor()\n Return the current background color as color specification\n string or as a tuple (see example). May be used as input\n to another color/pencolor/fillcolor/bgcolor call.\n - bgcolor(colorstring)\n Set the background color to colorstring, which is a Tk color\n specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n - bgcolor((r, g, b))\n Set the background color to the RGB color represented by\n the tuple of r, g, and b. Each of r, g, and b must be in\n the range 0..colormode, where colormode is either 1.0 or 255\n (see colormode()).\n - bgcolor(r, g, b)\n Set the background color to the RGB color represented by\n r, g, and b. Each of r, g, and b must be in the range\n 0..colormode.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgcolor(\"orange\")\n>>> screen.bgcolor()\n'orange'\n>>> colormode(255)\n>>> screen.bgcolor('#800080')\n>>> screen.bgcolor()\n(128.0, 0.0, 128.0)\n", + "_Screen.bgpic": "Set background image or return name of current backgroundimage.\n\nOptional argument:\npicname -- a string, name of an image file (PNG, GIF, PGM, and PPM) or \"nopic\".\n\nIf picname is a filename, set the corresponding image as background.\nIf picname is \"nopic\", delete backgroundimage, if present.\nIf picname is None, return the filename of the current backgroundimage.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bgpic()\n'nopic'\n>>> screen.bgpic(\"landscape.gif\")\n>>> screen.bgpic()\n'landscape.gif'\n", + "_Screen.bye": "Shut the turtlegraphics window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.bye()\n", + "_Screen.clearscreen": "Delete all drawings and all turtles from the TurtleScreen.\n\nNo argument.\n\nReset empty TurtleScreen to its initial state: white background,\nno backgroundimage, no eventbindings and tracing on.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.clear()\n\nNote: this method is not available as function.\n", + "_Screen.colormode": "Return the colormode or set it to 1.0 or 255.\n\nOptional argument:\ncmode -- one of the values 1.0 or 255\n\nr, g, b values of colortriples have to be in range 0..cmode.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.colormode()\n1.0\n>>> screen.colormode(255)\n>>> pencolor(240,160,80)\n", + "_Screen.delay": "Return or set the drawing delay in milliseconds.\n\nOptional argument:\ndelay -- positive integer\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.delay(15)\n>>> screen.delay()\n15\n", + "_Screen.exitonclick": "Go into mainloop until the mouse is clicked.\n\nNo arguments.\n\nBind bye() method to mouseclick on TurtleScreen.\nIf \"using_IDLE\" - value in configuration dictionary is False\n(default value), enter mainloop.\nIf IDLE with -n switch (no subprocess) is used, this value should be\nset to True in turtle.cfg. In this case IDLE's mainloop\nis active also for the client script.\n\nThis is a method of the Screen-class and not available for\nTurtleScreen instances.\n\nExample (for a Screen instance named screen):\n>>> screen.exitonclick()\n\n", + "_Screen.getcanvas": "Return the Canvas of this TurtleScreen.\n\nNo argument.\n\nExample (for a Screen instance named screen):\n>>> cv = screen.getcanvas()\n>>> cv\n\n", + "_Screen.getshapes": "Return a list of names of all currently available turtle shapes.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.getshapes()\n['arrow', 'blank', 'circle', ... , 'turtle']\n", + "_Screen.listen": "Set focus on TurtleScreen (in order to collect key-events)\n\nNo arguments.\nDummy arguments are provided in order\nto be able to pass listen to the onclick method.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.listen()\n", + "_Screen.mainloop": "Starts event loop - calling Tkinter's mainloop function.\n\nNo argument.\n\nMust be last statement in a turtle graphics program.\nMust NOT be used if a script is run from within IDLE in -n mode\n(No subprocess) - for interactive use of turtle graphics.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.mainloop()\n\n", + "_Screen.mode": "Set turtle-mode ('standard', 'logo' or 'world') and perform reset.\n\nOptional argument:\nmode -- one of the strings 'standard', 'logo' or 'world'\n\nMode 'standard' is compatible with turtle.py.\nMode 'logo' is compatible with most Logo-Turtle-Graphics.\nMode 'world' uses userdefined 'worldcoordinates'. *Attention*: in\nthis mode angles appear distorted if x/y unit-ratio doesn't equal 1.\nIf mode is not given, return the current mode.\n\n Mode Initial turtle heading positive angles\n ------------|-------------------------|-------------------\n 'standard' to the right (east) counterclockwise\n 'logo' upward (north) clockwise\n\nExamples:\n>>> mode('logo') # resets turtle heading to north\n>>> mode()\n'logo'\n", + "_Screen.no_animation": "Temporarily turn off auto-updating the screen.\n\nThis is useful for drawing complex shapes where even the fastest setting\nis too slow. Once this context manager is exited, the drawing will\nbe displayed.\n\nExample (for a TurtleScreen instance named screen\nand a Turtle instance named turtle):\n>>> with screen.no_animation():\n... turtle.circle(50)\n", + "_Screen.numinput": "Pop up a dialog window for input of a number.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what numerical information to input.\ndefault: default value\nminval: minimum value for input\nmaxval: maximum value for input\n\nThe number input must be in the range minval .. maxval if these are\ngiven. If not, a hint is issued and the dialog remains open for\ncorrection. Return the number input.\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.numinput(\"Poker\", \"Your stakes:\", 1000, minval=10, maxval=10000)\n\n", + "_Screen.onkey": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onkeypress": "Bind fun to key-press event of key if key is given,\nor to any key-press-event if no key is given.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen\nand a Turtle instance named turtle):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkeypress(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, or by keeping pressed the up-arrow key.\nconsequently drawing a hexagon.\n", + "_Screen.onkeyrelease": "Bind fun to key-release event of key.\n\nArguments:\nfun -- a function with no arguments\nkey -- a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")\n\nIn order to be able to register key-events, TurtleScreen\nmust have focus. (See method listen.)\n\nExample (for a TurtleScreen instance named screen):\n\n>>> def f():\n... fd(50)\n... lt(60)\n...\n>>> screen.onkey(f, \"Up\")\n>>> screen.listen()\n\nSubsequently the turtle can be moved by repeatedly pressing\nthe up-arrow key, consequently drawing a hexagon\n\n", + "_Screen.onscreenclick": "Bind fun to mouse-click event on canvas.\n\nArguments:\nfun -- a function with two arguments, the coordinates of the\n clicked point on the canvas.\nbtn -- the number of the mouse-button, defaults to 1\n\nExample (for a TurtleScreen instance named screen)\n\n>>> screen.onclick(goto)\n>>> # Subsequently clicking into the TurtleScreen will\n>>> # make the turtle move to the clicked point.\n>>> screen.onclick(None)\n", + "_Screen.ontimer": "Install a timer, which calls fun after t milliseconds.\n\nArguments:\nfun -- a function with no arguments.\nt -- a number >= 0\n\nExample (for a TurtleScreen instance named screen):\n\n>>> running = True\n>>> def f():\n... if running:\n... fd(50)\n... lt(60)\n... screen.ontimer(f, 250)\n...\n>>> f() # makes the turtle marching around\n>>> running = False\n", + "_Screen.register_shape": "Adds a turtle shape to TurtleScreen's shapelist.\n\nArguments:\n(1) name is the name of an image file (PNG, GIF, PGM, and PPM) and shape is None.\n Installs the corresponding image shape.\n !! Image-shapes DO NOT rotate when turning the turtle,\n !! so they do not display the heading of the turtle!\n(2) name is an arbitrary string and shape is the name of an image file (PNG, GIF, PGM, and PPM).\n Installs the corresponding image shape.\n !! Image-shapes DO NOT rotate when turning the turtle,\n !! so they do not display the heading of the turtle!\n(3) name is an arbitrary string and shape is a tuple\n of pairs of coordinates. Installs the corresponding\n polygon shape\n(4) name is an arbitrary string and shape is a\n (compound) Shape object. Installs the corresponding\n compound shape.\nTo use a shape, you have to issue the command shape(shapename).\n\ncall: register_shape(\"turtle.gif\")\n--or: register_shape(\"tri\", ((0,0), (10,10), (-10,10)))\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.register_shape(\"triangle\", ((5,-3),(0,5),(-5,-3)))\n\n", + "_Screen.resetscreen": "Reset all Turtles on the Screen to their initial state.\n\nNo argument.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.reset()\n", + "_Screen.save": "Save the drawing as a PostScript file\n\nArguments:\nfilename -- a string, the path of the created file.\n Must end with '.ps' or '.eps'.\n\nOptional arguments:\noverwrite -- boolean, if true, then existing files will be overwritten\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.save('my_drawing.eps')\n", + "_Screen.screensize": "Resize the canvas the turtles are drawing on.\n\nOptional arguments:\ncanvwidth -- positive integer, new width of canvas in pixels\ncanvheight -- positive integer, new height of canvas in pixels\nbg -- colorstring or color-tuple, new backgroundcolor\nIf no arguments are given, return current (canvaswidth, canvasheight)\n\nDo not alter the drawing window. To observe hidden parts of\nthe canvas use the scrollbars. (Can make visible those parts\nof a drawing, which were outside the canvas before!)\n\nExample (for a Turtle instance named turtle):\n>>> turtle.screensize(2000,1500)\n>>> # e.g. to search for an erroneously escaped turtle ;-)\n", + "_Screen.setup": "Set the size and position of the main window.\n\nArguments:\nwidth: as integer a size in pixels, as float a fraction of the screen.\n Default is 50% of screen.\nheight: as integer the height in pixels, as float a fraction of the\n screen. Default is 75% of screen.\nstartx: if positive, starting position in pixels from the left\n edge of the screen, if negative from the right edge\n Default, startx=None is to center window horizontally.\nstarty: if positive, starting position in pixels from the top\n edge of the screen, if negative from the bottom edge\n Default, starty=None is to center window vertically.\n\nExamples (for a Screen instance named screen):\n>>> screen.setup (width=200, height=200, startx=0, starty=0)\n\nsets window to 200x200 pixels, in upper left of screen\n\n>>> screen.setup(width=.75, height=0.5, startx=None, starty=None)\n\nsets window to 75% of screen by 50% of screen and centers\n", + "_Screen.setworldcoordinates": "Set up a user defined coordinate-system.\n\nArguments:\nllx -- a number, x-coordinate of lower left corner of canvas\nlly -- a number, y-coordinate of lower left corner of canvas\nurx -- a number, x-coordinate of upper right corner of canvas\nury -- a number, y-coordinate of upper right corner of canvas\n\nSet up user coodinat-system and switch to mode 'world' if necessary.\nThis performs a screen.reset. If mode 'world' is already active,\nall drawings are redrawn according to the new coordinates.\n\nBut ATTENTION: in user-defined coordinatesystems angles may appear\ndistorted. (see Screen.mode())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.setworldcoordinates(-10,-0.5,50,1.5)\n>>> for _ in range(36):\n... left(10)\n... forward(0.5)\n", + "_Screen.textinput": "Pop up a dialog window for input of a string.\n\nArguments: title is the title of the dialog window,\nprompt is a text mostly describing what information to input.\n\nReturn the string input\nIf the dialog is canceled, return None.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.textinput(\"NIM\", \"Name of first player:\")\n\n", + "_Screen.title": "Set title of turtle-window\n\nArgument:\ntitlestring -- a string, to appear in the titlebar of the\n turtle graphics window.\n\nThis is a method of Screen-class. Not available for TurtleScreen-\nobjects.\n\nExample (for a Screen instance named screen):\n>>> screen.title(\"Welcome to the turtle-zoo!\")\n", + "_Screen.tracer": "Turns turtle animation on/off and set delay for update drawings.\n\nOptional arguments:\nn -- nonnegative integer\ndelay -- nonnegative integer\n\nIf n is given, only each n-th regular screen update is really performed.\n(Can be used to accelerate the drawing of complex graphics.)\nSecond arguments sets delay value (see RawTurtle.delay())\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.tracer(8, 25)\n>>> dist = 2\n>>> for i in range(200):\n... fd(dist)\n... rt(90)\n... dist += 2\n", + "_Screen.turtles": "Return the list of turtles on the screen.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.turtles()\n[]\n", + "_Screen.update": "Perform a TurtleScreen update.\n ", + "_Screen.window_height": "Return the height of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_height()\n480\n", + "_Screen.window_width": "Return the width of the turtle window.\n\nExample (for a TurtleScreen instance named screen):\n>>> screen.window_width()\n640\n", + "write_docstringdict": "Create and write docstring-dictionary to file.\n\nOptional argument:\nfilename -- a string, used as filename\n default value is turtle_docstringdict\n\nHas to be called explicitly, (not used by the turtle-graphics classes)\nThe docstring dictionary will be written to the Python script .py\nIt is intended to serve as a template for translation of the docstrings\ninto different languages.\n" + } + } +} diff --git a/tests/test_i18n.py b/tests/test_i18n.py new file mode 100644 index 0000000..e004eda --- /dev/null +++ b/tests/test_i18n.py @@ -0,0 +1,203 @@ +"""Catalog compilation and version selection regressions.""" + +import ast +import importlib.util +import shutil +import subprocess +import sys +import tempfile +import types +import unittest +from pathlib import Path +from unittest.mock import patch + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts")) + +import i18n +import sources + +ROOT = Path(__file__).resolve().parent.parent + + +class CatalogTests(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + self.data = sources.read_sources() + + def test_union_contains_every_source_and_method(self): + catalog = i18n.build_template(self.data) + originals = set() + for version, info in self.data["versions"].items(): + for key, original in self.data["groups"][info["group"]].items(): + originals.add(original) + message = catalog.get(original) + self.assertTrue(any(comment.startswith(f"turtle.{key} (Python ") + for comment in message.auto_comments)) + self.assertEqual(len(catalog), len(originals)) + + def test_comments_group_versions_per_method_without_filling_gaps(self): + data = { + "versions": {version: {"group": version} + for version in ("3.11", "3.12", "3.13", "3.14")}, + "groups": { + "3.11": {"Turtle.left": "Shared", "Turtle.right": "Shared"}, + "3.12": {"Turtle.left": "Shared"}, + "3.13": {"Turtle.left": "Changed"}, + "3.14": {"Turtle.left": "Shared"}, + }, + } + catalog = i18n.build_template(data) + self.assertEqual(catalog.get("Shared").auto_comments, [ + "turtle.Turtle.left (Python 3.11–3.12, 3.14)", + "turtle.Turtle.right (Python 3.11)", + ]) + self.assertEqual(catalog.get("Changed").auto_comments, [ + "turtle.Turtle.left (Python 3.13)", + ]) + + def test_newest_docstrings_precede_older_variants(self): + data = { + "versions": {version: {"group": version} + for version in ("3.10", "3.9", "3.11")}, + "groups": { + "3.9": {"Turtle.left": "Oldest", "Turtle.right": "Shared"}, + "3.10": {"Turtle.left": "Older", "Turtle.right": "Shared", + "Turtle.removed": "Removed"}, + "3.11": {"Turtle.left": "Newest", "Turtle.right": "Shared"}, + }, + } + template = i18n.build_template(data) + expected = ["Newest", "Shared", "Older", "Removed", "Oldest"] + self.assertEqual([message.id for message in template if message.id], expected) + self.assertEqual(template.version, "3.9–3.11") + + catalog = i18n.Catalog(locale="pl") + for original in reversed(expected): + catalog.add(original, string=f"Translation: {original}") + catalog.update(template) + path = self.root / "pl.po" + i18n.write_catalog(catalog, path) + messages = [message for message in i18n.read_catalog(path) if message.id] + self.assertEqual([message.id for message in messages], expected) + for message in messages: + self.assertEqual(message.string, f"Translation: {message.id}") + self.assertFalse(message.fuzzy) + + def test_matching_requires_original_and_reviewed_translation(self): + catalog = i18n.build_template(self.data) + for message in catalog: + if message.id: + message.string = f"Translation: {message.id}" + docs = self.data["groups"]["3.11"] + catalog.get(docs["Turtle.forward"]).flags.add("fuzzy") + catalog.get(docs["Turtle.back"]).string = "" + catalog.get(docs["Turtle.left"]).auto_comments = ["turtle.WrongMethod"] + catalog.get(docs["Turtle.right"]).auto_comments = [] + path = self.root / "pl.po" + i18n.write_catalog(catalog, path) + compiled = i18n._load_docsdict(path, docs) + for key in ("Turtle.forward", "Turtle.back"): + self.assertNotIn(key, compiled) + for key in ("Turtle.left", "Turtle.right"): + self.assertEqual(compiled[key], f"Translation: {docs[key]}") + self.assertIn("Turtle.settiltangle", compiled) + self.assertNotIn("Turtle.teleport", compiled) + self.assertEqual(compiled["Turtle.tiltangle"], f"Translation: {docs['Turtle.tiltangle']}") + newer = i18n._load_docsdict(path, self.data["groups"]["3.14"]) + self.assertNotIn("Turtle.settiltangle", newer) + self.assertIn("Turtle.teleport", newer) + self.assertIn("_Screen.save", newer) + self.assertNotEqual(compiled["Turtle.tiltangle"], newer["Turtle.tiltangle"]) + + def test_new_source_does_not_reuse_old_translation(self): + catalog = i18n.build_template(self.data) + original = self.data["groups"]["3.11"]["Turtle.tiltangle"] + catalog.get(original).string = "Old translation" + path = self.root / "pl.po" + i18n.write_catalog(catalog, path) + self.assertEqual(i18n._load_docsdict(path, {"Turtle.tiltangle": original}), + {"Turtle.tiltangle": "Old translation"}) + self.assertEqual(i18n._load_docsdict(path, {"Turtle.tiltangle": "Changed text"}), {}) + + def test_update_preserves_existing_translation(self): + catalog = i18n.build_template(self.data) + original = self.data["groups"]["3.11"]["Turtle.forward"] + catalog.get(original).string = "Naprzód" + catalog.update(i18n.build_template(self.data)) + self.assertEqual(catalog.get(original).string, "Naprzód") + self.assertFalse(catalog.get(original).fuzzy) + + def test_compilation_and_language_discovery(self): + catalog = i18n.build_template(self.data) + for lang in ("pl", "pt_BR"): + i18n.write_catalog(catalog, self.root / f"{lang}.po") + with patch.object(i18n, "PO_DIR", self.root): + paths = i18n._compile_catalogs(self.root) + self.assertEqual(len(paths), 12) + self.assertTrue((self.root / "turtle_docstringdict_pt_br.py").is_file()) + self.assertTrue((self.root / "turtle_translations" / "pl" / "py311.py").is_file()) + self.assertFalse((self.root / "turtle_translations" / "pl" / "py310.py").exists()) + for path in paths: + ast.parse(path.read_text(encoding="utf-8"), feature_version=(3, 10)) + spec = importlib.util.spec_from_file_location( + "fixture_translations", ROOT / "turtle_translations" / "__init__.py", + submodule_search_locations=[str(self.root / "turtle_translations")], + ) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + self.assertEqual(module.available(), ["pl", "pt_br"]) + + def test_shim_dispatch_and_import_isolation(self): + modules = {} + for group in self.data["groups"]: + name = f"turtle_translations.{i18n._module_name('pl', group)}" + modules[name] = types.SimpleNamespace(docsdict={"group": group}) + modules.update({"turtle": None, "tkinter": None, "babel": None}) + cases = [(2, 7, "3.11"), (3, 9, "3.11")] + cases += [(3, minor, f"3.{min(minor, 14)}") for minor in range(11, 18)] + cases.append((4, 0, "3.14")) + code = i18n._render_shim("pl", self.data) + for major, minor, group in cases: + for release in ("alpha", "final"): + with self.subTest(version=(major, minor, release)): + with patch.dict(sys.modules, modules), patch.object( + sys, "version_info", (major, minor, 0, release, 0) + ): + namespace = {} + exec(code, namespace) + self.assertEqual(namespace["docsdict"], {"group": group}) + + def test_fresh_turtle_import_with_translated_fixture(self): + # A separate process ensures configuration is applied before turtle's + # module-level wrappers copy the translated method docstrings. + catalog = i18n.build_template(self.data) + for message in catalog: + if message.id: + message.string = "Polish fixture: " + message.id + path = self.root / "pl.po" + i18n.write_catalog(catalog, path) + with patch.object(i18n, "po_files", return_value=[path]): + i18n._compile_catalogs(self.root) + shutil.copyfile(ROOT / "turtle_translations" / "__init__.py", + self.root / "turtle_translations" / "__init__.py") + (self.root / "turtle.cfg").write_text("language = pl\n", encoding="utf-8") + result = subprocess.run( + [sys.executable, "-c", ''' +import turtle +import turtle_docstringdict_pl +assert turtle_docstringdict_pl.docsdict +assert turtle.Turtle.forward.__doc__.startswith("Polish fixture: ") +assert turtle.forward.__doc__.startswith("Polish fixture: ") +assert turtle.fd.__doc__ == turtle.forward.__doc__ +assert turtle.Screen.__doc__.startswith("Polish fixture: ") +'''], cwd=self.root, text=True, capture_output=True, + ) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual(result.stdout, "") + self.assertEqual(result.stderr, "") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_package.py b/tests/test_package.py new file mode 100644 index 0000000..53732b9 --- /dev/null +++ b/tests/test_package.py @@ -0,0 +1,71 @@ +"""Exercise the wheel's actual loader contract with translated fixture data.""" + +import shutil +import subprocess +import sys +import tempfile +import unittest +import zipfile +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts")) + +import i18n + +ROOT = Path(__file__).resolve().parent.parent + + +class PackageTests(unittest.TestCase): + def test_wheel_with_translations_and_stale_legacy_module(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + for name in ("scripts", "sources", "turtle_translations"): + shutil.copytree(ROOT / name, root / name, + ignore=shutil.ignore_patterns("__pycache__")) + for name in ("pyproject.toml", "README.md", "LICENSE", ".gitignore"): + shutil.copyfile(ROOT / name, root / name) + catalog = i18n.build_template() + for message in catalog: + if message.id: + message.string = "Polish fixture: " + message.id + i18n.write_catalog(catalog, root / "po" / "pl.po") + (root / "turtle_translations" / "pl.py").write_text("raise RuntimeError\n") + result = subprocess.run( + [sys.executable, "-m", "hatchling", "build", "-t", "wheel"], + cwd=root, capture_output=True, text=True, + ) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + wheel = next((root / "dist").glob("*.whl")) + with zipfile.ZipFile(wheel) as archive: + names = archive.namelist() + self.assertIn("turtle_docstringdict_pl.py", names) + self.assertNotIn("turtle_translations/pl.py", names) + for group in (311, 312, 313, 314): + self.assertIn(f"turtle_translations/pl/py{group}.py", names) + runtime = root / "runtime" + runtime.mkdir() + (runtime / "turtle.cfg").write_text("language = pl\n") + result = subprocess.run( + [sys.executable, "-I", "-c", ''' +import sys +sys.path.insert(0, sys.argv[1]) +import turtle_docstringdict_pl as pl +assert pl.docsdict +assert "turtle" not in sys.modules +assert "tkinter" not in sys.modules +assert "babel" not in sys.modules +import turtle_translations +assert turtle_translations.available() == ["pl"] +import turtle +assert turtle.Turtle.forward.__doc__.startswith("Polish fixture: ") +assert turtle.forward.__doc__.startswith("Polish fixture: ") +assert turtle.fd.__doc__ == turtle.forward.__doc__ +''', str(wheel)], cwd=runtime, capture_output=True, text=True, + ) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual(result.stdout, "") + self.assertEqual(result.stderr, "") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_sources.py b/tests/test_sources.py new file mode 100644 index 0000000..6f37ab2 --- /dev/null +++ b/tests/test_sources.py @@ -0,0 +1,83 @@ +"""Source extraction checks, independent of the adjacent CPython checkout.""" + +import ast +import sys +import unittest +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts")) + +import sources + + +class SourceTests(unittest.TestCase): + def test_recorded_version_differences(self): + data = sources.read_sources() + self.assertEqual(list(data["versions"]), [f"3.{n}" for n in range(11, 17)]) + self.assertEqual([len(docs) for docs in data["groups"].values()], + [102, 103, 102, 106]) + for minor in (14, 15, 16): + self.assertEqual(data["versions"][f"3.{minor}"]["group"], "3.14") + groups = data["groups"] + for old, new, added, removed, changed in ( + ("3.11", "3.12", 1, 0, 3), + ("3.12", "3.13", 0, 1, 9), + ("3.13", "3.14", 4, 0, 2), + ): + before, after = groups[old], groups[new] + self.assertEqual(len(after.keys() - before.keys()), added) + self.assertEqual(len(before.keys() - after.keys()), removed) + self.assertEqual(sum(before[k] != after[k] for k in before.keys() & after.keys()), + changed) + + def test_inheritance_aliases_and_unexecuted_source(self): + source = ''' +raise RuntimeError("Must never execute the source") +_tg_screen_functions = ["clear"] +_tg_turtle_functions = ["forward", "fd"] +_alias_list = ["fd"] +__all__ = _tg_screen_functions + _tg_turtle_functions + ["Turtle"] +class Base: + def forward(self): + """Move forward. + Preserve indentation. + """ + fd = forward +class Turtle(Base): + """A turtle.""" +class ScreenBase: + def clear(self): + """Clear the screen.""" +class _Screen(ScreenBase): + pass +''' + docs = sources.extract_docstrings(source) + self.assertEqual(set(docs), {"Turtle.forward", "_Screen.clear", "Turtle"}) + self.assertEqual(docs["Turtle.forward"], "Move forward.\nPreserve indentation.\n") + tree = ast.parse(source) + tree.body[3].value = ast.List(elts=[], ctx=ast.Load()) + docs = sources.extract_docstrings(ast.unparse(tree)) + self.assertEqual(docs["Turtle.fd"], docs["Turtle.forward"]) + + def test_extraction_matches_running_turtle(self): + import turtle + + docs = sources.extract_docstrings(Path(turtle.__file__).read_text(encoding="utf-8")) + skip = set(turtle._alias_list) | {"Pen", "RawPen", "done"} + expected = {} + for name in turtle.__all__: + if name in skip: + continue + if name in turtle._tg_screen_functions: + key, obj = f"_Screen.{name}", getattr(turtle._Screen, name) + elif name in turtle._tg_turtle_functions: + key, obj = f"Turtle.{name}", getattr(turtle.Turtle, name) + else: + key, obj = name, getattr(turtle, name) + if obj.__doc__: + expected[key] = sources.normalize_docstring(obj.__doc__) + self.assertEqual(docs, expected) + + +if __name__ == "__main__": + unittest.main() diff --git a/turtle_translations/__init__.py b/turtle_translations/__init__.py index 7c02458..98aee08 100644 --- a/turtle_translations/__init__.py +++ b/turtle_translations/__init__.py @@ -5,7 +5,4 @@ def available(): """Return a list of the available languages.""" - return sorted( - info.name for info in pkgutil.iter_modules(__path__) - if not info.name.startswith("_") - ) + return sorted(info.name for info in pkgutil.iter_modules(__path__) if info.ispkg)