Skip to main content

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

basthon_turtle-0.1.2.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basthon_turtle-0.1.2-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file basthon_turtle-0.1.2.tar.gz.

File metadata

  • Download URL: basthon_turtle-0.1.2.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for basthon_turtle-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4aaf9fd648789c3e05f4858a002f3860cd6dbc89a114de087a9c9f9f4a12af55
MD5 d4e0d493619165edfafcaed192294525
BLAKE2b-256 0e7135cd39da523778b8aaee241935d3a6c3d783d17f138ca4d96e2c7b4fac31

See more details on using hashes here.

File details

Details for the file basthon_turtle-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: basthon_turtle-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for basthon_turtle-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ecbd8a104fee01a8118a8458f2df2888b40d02ce096bc99823efbaa93c36f339
MD5 d7b09b91d5455ac00e413813921251eb
BLAKE2b-256 77fa150aa11280fa3a6ca21b7673b0901a32d4abb91f7e0c4ec8eac6d47d835c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page