Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3379b3d
Add context managers for turtle.fill and turtle.poly
yngvem Oct 6, 2024
879d886
Add documentation
MarieRoald Oct 20, 2024
54f709c
Add context manager to turtle.TurtleScreen for disabling auto-update
MarieRoald Oct 27, 2024
437c8ce
Forward functions correctly
yngvem Oct 27, 2024
d11d8f9
Add documentation
yngvem Oct 27, 2024
1f04ee4
πŸ“œπŸ€– Added by blurb_it.
blurb-it[bot] Nov 3, 2024
3947de1
Fix typo in docs
MarieRoald Nov 3, 2024
5ee489b
Apply suggestions from code review
MarieRoald Nov 8, 2024
28a5ac6
Address review comments
MarieRoald Nov 8, 2024
6621bd3
Apply suggestions from code review
MarieRoald Nov 8, 2024
2f5c488
Address review comments
MarieRoald Nov 8, 2024
302a1ed
Apply suggestions from code review
MarieRoald Nov 9, 2024
ad779d5
Use setUp for unit tests
yngvem Nov 9, 2024
fd89c95
Address review comments
yngvem Nov 9, 2024
fe39751
Add missing blank line
MarieRoald Nov 9, 2024
0a5e250
Update Lib/turtle.py
MarieRoald Nov 9, 2024
6d381ec
Apply suggestions from code review
MarieRoald Nov 14, 2024
42d678d
Update Lib/turtle.py
MarieRoald Nov 14, 2024
7928306
Address reviewer comments
MarieRoald Nov 14, 2024
815a8a3
Update Lib/test/test_turtle.py
MarieRoald Dec 18, 2024
fc01695
Merge branch 'main' into fix-issue-126349
hugovk Dec 29, 2024
8487336
Re-sort
hugovk Dec 29, 2024
401c07f
Merge branch 'main' into fix-issue-126349
erlend-aasland Dec 30, 2024
3f2b4ef
Pull in main and resolve conflicts
erlend-aasland Dec 30, 2024
0c2fca0
Remove unneeded stylistic change; remove unprintable char from NEWS e…
erlend-aasland Dec 30, 2024
6115eef
Change assert to self.assertEqual
MarieRoald Jan 5, 2025
11d9bc3
Change assert to self.assertEqual
MarieRoald Jan 18, 2025
061fe2a
Improve usage of unittest.mock.patch
MarieRoald Jan 18, 2025
32bbf68
Merge branch 'main' into fix-issue-126349
MarieRoald Jan 18, 2025
b2ab84b
Merge branch 'main' into fix-issue-126349
MarieRoald Jan 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add documentation
Co-authored-by: Marie Roald <[email protected]>
  • Loading branch information
yngvem and MarieRoald committed Nov 3, 2024
commit d11d8f99c8d5ff0f4418631bd52ecc0f066d3a53
85 changes: 85 additions & 0 deletions Doc/library/turtle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@ useful when working with learners for whom typing is not a skill.
use turtle graphics with a learner.


Automatically begin and end filling
-----------------------------------

If you have Python 3.14 or later, you don't need to call :func:`begin_fill` and
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
:func:`end_fill` for filling. Instead, you can use the :func:`fill`
:term:`context manager` to automatically begin and end fill. Here is an
example::

with fill():
for i in range(4):
forward(100)
right(90)

forward(200)
Comment thread
picnixz marked this conversation as resolved.

The code above is equivalent to::

begin_fill()
Comment thread
picnixz marked this conversation as resolved.
for i in range(4):
forward(100)
right(90)
end_fill()

forward(200)
Comment thread
MarieRoald marked this conversation as resolved.


Use the ``turtle`` module namespace
-----------------------------------

Expand Down Expand Up @@ -381,6 +407,7 @@ Using events
| :func:`ondrag`

Special Turtle methods
| :func:`poly`
| :func:`begin_poly`
| :func:`end_poly`
| :func:`get_poly`
Expand All @@ -403,6 +430,7 @@ Window control
| :func:`setworldcoordinates`

Animation control
| :func:`no_animation`
| :func:`delay`
| :func:`tracer`
| :func:`update`
Expand Down Expand Up @@ -1275,6 +1303,29 @@ Filling
... else:
... turtle.pensize(3)

.. function:: fill()
Comment thread
hugovk marked this conversation as resolved.

Fill the shape drawn in the ``with turtle.fill():`` block.

.. doctest::
:skipif: _tkinter is None

>>> turtle.color("black", "red")
>>> with turtle.fill():
... turtle.circle(80)

Using ``fill`` is equivalent to adding the :func:`begin_fill` before the
Comment thread
MarieRoald marked this conversation as resolved.
Outdated
fill-block and :func:`end_fill` after the fill-block
Comment thread
MarieRoald marked this conversation as resolved.
Outdated

.. doctest::
:skipif: _tkinter is None

>>> turtle.color("black", "red")
>>> turtle.begin_fill()
>>> turtle.circle(80)
>>> turtle.end_fill()

.. versionadded:: 3.14
Comment thread
MarieRoald marked this conversation as resolved.
Outdated


.. function:: begin_fill()
Expand Down Expand Up @@ -1648,6 +1699,22 @@ Using events
Special Turtle methods
----------------------


.. function:: poly()

Record the vertices of a polygon. The first and last vertices will be
Comment thread
MarieRoald marked this conversation as resolved.
Outdated
connected.

.. doctest::
:skipif: _tkinter is None

>>> with turtle.poly():
... turtle.forward(100)
... turtle.right(60)
... turtle.forward(100)

.. versionadded:: 3.14
Comment thread
MarieRoald marked this conversation as resolved.
Outdated

Comment thread
picnixz marked this conversation as resolved.
.. function:: begin_poly()

Start recording the vertices of a polygon. Current turtle position is first
Expand Down Expand Up @@ -1925,6 +1992,24 @@ Window control
Animation control
-----------------

.. function:: no_animation()

Temporarilly disable turtle animation. The code written inside the
Comment thread
MarieRoald marked this conversation as resolved.
Outdated
``no_animation`` block will not be animated, and once the code block is
exitted, the drawing will appear.
Comment thread
MarieRoald marked this conversation as resolved.
Outdated

.. doctest::
:skipif: _tkinter is None

>>> with screen.no_animation():
... for i in range(200):
... fd(dist)
... rt(90)
... dist += 2


Comment thread
MarieRoald marked this conversation as resolved.
Outdated
.. versionadded:: 3.14
Comment thread
MarieRoald marked this conversation as resolved.
Outdated

.. function:: delay(delay=None)

:param delay: positive integer
Expand Down