A revised version of CPython’s turtle module, browser-friendly.
The optional standalone mode supports interactive CPython use. The abbreviated docstrings remain less suitable for help() than CPython’s implementation.
All public methods/functions of the CPython version should exist, if only to print out a warning that they are not implemented. The intent is to make it easier to “port” any existing turtle program from CPython to the browser.
Initially the code was part of Brython, then ported to Basthon, then published as a standalone package.
Installation
pip install basthon-turtle
For a live, persistent browser window in a regular CPython session, install the proof-of-concept standalone extra:
pip install "basthon-turtle[standalone]"
or
import micropip
await micropip.install('basthon-turtle')
Usage
Note: if running multiple times you need to restart the state of screen with turtle.restart() function.
Standalone CPython
The browser starts lazily on the first visible turtle operation. It remains alive between commands and receives incremental drawing updates:
from turtle import forward, left
forward(100)
left(90)
forward(50)
Jupyter
from IPython.display import HTML
from turtle import forward, done, svg
forward(100)
done()
HTML(svg())
Marimo
import marimo as mo
from turtle import forward, done, svg
forward(100)
done()
forward(100)
mo.Html(svg())
Credits
bearney74
André Roberge
Romain Casati
Implementation
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 basthon_turtle-0.1.0.tar.gz.
File metadata
- Download URL: basthon_turtle-0.1.0.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40da9f44bbe3524567d109d73e26d772396d6cec9e713bb567e6777e54a79011
|
|
| MD5 |
7ad2981d60fe5284ab01ef80851a635c
|
|
| BLAKE2b-256 |
f55ddb16c35fbd474e7e271d0b439ed2e0726199749c60b9f903c53e45054ea9
|
File details
Details for the file basthon_turtle-0.1.0-py3-none-any.whl.
File metadata
- Download URL: basthon_turtle-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d47c8eb675a1fb30c0ad92523386257b0ac585bf5eede5b1d9108079381e9326
|
|
| MD5 |
9706b7b742e77773146a5241f3902c3e
|
|
| BLAKE2b-256 |
b65f6bea6ca9e70b8aa8f01dbf39807e962c58f37b6a51af43fc67e35eb180c1
|