Skip to main content

Turtle graphics for Jupyter Notebooks

Project description

jupyturtle

Python Turtle graphics for Jupyter notebooks

For a quick demo, open the lab notebook.

No installation required, just download the jupyter.py module to the same folder where your notebook is saved, and import it.

Credits

The idea and some of the code for this module came from Tolga Atam's ColabTurtle, which I discovered reading a pre-print version of Allen Downey's book Think Python, Third Edition (O'Reilly, 2024).

Design

Atam's best idea was to use SVG for drawing, which makes the code simple and lightweight, requiring only the Python standard library and the ipython module that is always available in Jupyter.

This is a rewrite from scratch, using classes to model the turtle and the drawing. My goal was to make it easier to understand and extend by encapsulating the state.

I used metaprogramming techniques to build the procedural API with global functions like fd() to move the turtle. The techniques are easier to understand in the didactic project abacus.

Turtle on a canvas

jupyturtle2 is a fork that uses ipycanvas to draw pixels on an HTML canvas, instead of generating SVG, so it handles complex drawings better.

But jupyturtle2 has two main drawbacks:

  • ipycanvas requires the binary dependencies numpy and pillow, which may be harder to install in some environments.

  • the generated drawings are not saved with the notebook like most other output cells; this is also a limitation of ipycanvas

@ramalho

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

jupyturtle-2024.3.30.tar.gz (131.2 kB view details)

Uploaded Source

Built Distribution

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

jupyturtle-2024.3.30-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file jupyturtle-2024.3.30.tar.gz.

File metadata

  • Download URL: jupyturtle-2024.3.30.tar.gz
  • Upload date:
  • Size: 131.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for jupyturtle-2024.3.30.tar.gz
Algorithm Hash digest
SHA256 03e2ec3c1e939f7a9fa8b30e5b0b590b6168c1b669ae987012f2b931ab5d4ed7
MD5 f453aefdcb0eda5dc865057a7fa8328d
BLAKE2b-256 19fea2f7d6a0938aa1693b7649ce002a5f931b8ba2418c67de3a339157885ead

See more details on using hashes here.

File details

Details for the file jupyturtle-2024.3.30-py3-none-any.whl.

File metadata

  • Download URL: jupyturtle-2024.3.30-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for jupyturtle-2024.3.30-py3-none-any.whl
Algorithm Hash digest
SHA256 54d5dced8b67850c5afed3e302f0d957c98d6e96ebed3a132b7ef2708036b13b
MD5 b8f41e3a0b5b9023c7bef0bb23b8d61a
BLAKE2b-256 c62db3190e086c80abc9cc657d4db112cbf90c60d554c954b617b76e68881eee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page