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.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

svg_turtle-1.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: svg_turtle-1.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for svg_turtle-1.1.0.tar.gz
Algorithm Hash digest
SHA256 21caebfa176e2cb2fe8e25d7c459d7672933c60e91133c2e4d97798f0412aa0a
MD5 fd911e56945a98b6102c072cddad2468
BLAKE2b-256 964568b385c616f930f68c5ea1665f81dcc5a09229f1aa3858110c3e0e1dcb2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svg_turtle-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for svg_turtle-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 912b3032383b8a5020b63a1930523d912d0142a3526e579418ca27dbead1c7d6
MD5 7081d01cff44c63c7d40076b386e5f4f
BLAKE2b-256 0cee6ace59347975715cc9f3718c79722f033c0a5695472688387831259251a2

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