Skip to main content

A revised version of CPython’s turtle module, browser-friendly.

Note: This version is not intended to be used in interactive mode, nor use help() to look up methods/functions definitions. The docstrings have thus been shortened considerably as compared with the CPython’s version.

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

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.

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())

webbrowser

import webbrowser
from urllib.parse import quote

from turtle import forward, done, svg


def show_svg(svg_content: str) -> None:
    html = f"<!doctype html><html><body>{svg_content}</body></html>"
    webbrowser.open(f"data:text/html,{quote(html)}")


forward(100)
done()

show_svg(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.0.2.tar.gz (32.2 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.0.2-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: basthon_turtle-0.0.2.tar.gz
  • Upload date:
  • Size: 32.2 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.0.2.tar.gz
Algorithm Hash digest
SHA256 d26db93e76a0ea18513d8d4ecf9c0bb8dbbc7b93ed3f95bc7854d26ad553d738
MD5 536a6d203a9516e05ffaba2e8a60f426
BLAKE2b-256 b45c46a61cfe6a0c85df4feeb240a212bb3195535c01e6b4b2d8b82076dcbe20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: basthon_turtle-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 34.3 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.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd586b4df0b3e396326ac6946cebb56ce87e5f31faf843b830622c13e9dd514c
MD5 27a6edd08b957c3723ac336de0f48952
BLAKE2b-256 e3d63b9d67feb9624e9bee97c11ad46a746bb4d06e8a002dcd8da4fc8024b26d

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

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

This release

0.0.2 This release

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