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.1.tar.gz (30.9 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.1-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: basthon_turtle-0.1.1.tar.gz
  • Upload date:
  • Size: 30.9 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.1.tar.gz
Algorithm Hash digest
SHA256 36b06839d232f8cd750d37342facf5a585b8114ea869d7b4439742a9df9718ed
MD5 0d04fde276d8fe9a6aacf1a103604444
BLAKE2b-256 07dab5b15277ef24697bda4a9b17ba9f37b0722c33db99ec6b9f21c37ba272f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: basthon_turtle-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a24109734bb09c2392aba0e6767b38922a3f4483f52951dbba15c43cbdc63de5
MD5 29556e85306871a12fdf556c9c1d1b18
BLAKE2b-256 97551a3be761181deeccf42b4215846c490c98409c6b07936f537f19bdc55346

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

0.1.2

2 files

This release

0.1.1 This release

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