An animated, turtle-compatible drawing widget for Jupyter notebooks
Project description
turtle-widget
An animated, turtle-compatible drawing
widget for Jupyter notebooks, built on anywidget.
You write ordinary turtle code in Python; the widget records each command and replays it as
a smooth canvas animation right below the cell. Because it is built on anywidget, it
behaves identically in VS Code, JupyterLab, Notebook 7, and Colab, and works
offline. Optionally it shows the cell source beside the canvas and highlights the active
line in sync with the animation (show_code=True).
Installation
# pixi
pixi workspace channel add munch-group
pixi add turtle-widget
# conda
conda install -c munch-group turtle-widget
# pip
pip install turtle-widget
Quick start
from turtle_widget import Turtle
t = Turtle()
t.speed(6)
for _ in range(4): # a square
t.forward(120)
t.left(90)
The widget appears automatically at the end of the cell — no need to put t on the last
line. You can also display it explicitly with t.show(), or evaluate t. Pass
autoshow=False to build a turtle without displaying it (useful for headless geometry
checks).
Most of the common turtle API is supported: forward/backward, left/right,
goto/setheading/home, circle, pen control (penup/pendown/pensize), colours
and fills (pencolor/fillcolor/begin_fill/end_fill), and markers/text
(dot/stamp/write). Note that the pen-width method is pensize() (the name width is
the canvas-size trait).
Documentation
Full docs and a guided showcase live at munch-group.org/turtle-widget.
Development
This repo is managed with pixi:
pixi run install-dev # editable install into the pixi environment
pixi run test # run the pytest suite
pixi run docs # execute the documentation notebooks
pixi run api # build the quartodoc API reference
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file turtle_widget-0.1.24.tar.gz.
File metadata
- Download URL: turtle_widget-0.1.24.tar.gz
- Upload date:
- Size: 458.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfc64d31a3280bbeed8141eafe9e5eb60fbbf4333c7fa5edbd643f27a1c1237e
|
|
| MD5 |
80e07a282149b972a7859e65ea4e3a8e
|
|
| BLAKE2b-256 |
0da61dfe67433a5d1d8a4c7f72c0853fc35b2bf5e295208cb9681c9e6c9d6ae6
|
File details
Details for the file turtle_widget-0.1.24-py3-none-any.whl.
File metadata
- Download URL: turtle_widget-0.1.24-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d524f584a343be3e70487726ec6b6d7b13f99ee853a35d60c07460eb6184cbd
|
|
| MD5 |
952fccd6a955dc081d2dc1d67716db1a
|
|
| BLAKE2b-256 |
e40ba92dcf04e4b08854db566cb98979d53353d69d60943caa0b5ebcbed1c4c1
|