Skip to main content

Use the Python turtle to write SVG files. With optional IPython integration.

Project description

SaVaGe Turtle Build Badge Coverage Badge Downloads Badge PyPI Badge Supported Python versions

Use the Python turtle to write SVG files

If you're using the Python turtle module to teach students, or you just like using the turtle module yourself, this library can save the images from a turtle script as SVG files. Experiment with your turtle code using the regular turtle or the Live Coding in Python plugin for PyCharm, then pass an SvgTurtle to the same code, and save it as an SVG file. If you want to produce other file formats, use svglib to convert the SVG to PDF, PNG, GIF, JPG, TIFF, and PCT, among others.

Installing

Install it with pip install svg_turtle. If you haven't installed Python packages before, read Brett Cannon's quick-and-dirty guide.

Drawing

Once it's installed, create an SvgTurtle, telling it how big to make the SVG file. Then give it some turtle commands, and save the file.

from svg_turtle import SvgTurtle

t = SvgTurtle(500, 500)
t.forward(200)
t.dot(10)
t.save_as('example.svg')

IPythonTurtle

To use SvgTurtle with IPython integration, create an instance of the IPythonTurtle class. It exposes the same interface as SvgTurtle. It implements both display on implicit return, and explicit display via the show() method.

from svg_turtle import IPythonTurtle

t = IPythonTurtle(500, 500)
t.forward(200)
t.show()                    # explicit display
t.dot(10)
t                           # display via implicit return

More Information

If you'd like to help out with the project, see the CONTRIBUTING.md file in the source code.

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

svg_turtle-1.0.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

svg_turtle-1.0.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file svg_turtle-1.0.0.tar.gz.

File metadata

  • Download URL: svg_turtle-1.0.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for svg_turtle-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6a5a36d7f1b7d2b12ec6a6029d08c81c11ab6385eb8f14d9765b1acf84501640
MD5 c03eb01bd1ca5b052ca88c38ef67b2ac
BLAKE2b-256 14e4d8844f23fb6ba69f9681121c6249865d87b86a4360e36168552289d9fde0

See more details on using hashes here.

File details

Details for the file svg_turtle-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: svg_turtle-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for svg_turtle-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 064b06a4ed210c31454ebf40d757e4b73a3543e960c5e75e1ebfa4c5a72f4c52
MD5 010dd74e84917d9b262945399f2e51fc
BLAKE2b-256 6461b35cc4cc9846eaef19fd858e8aed2d6327401f9fbe6d5e9fed1ef5625df5

See more details on using hashes here.

Supported by

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