Skip to main content

A Custom Jupyter Widget Library

Project description

Interactive Turtle

Build Status codecov

A custom Jupyter widget for interactive turtle.

Installation

You can install using pip:

pip install iturtle

Usage

Logo is an educational programming language, designed in 1967 by Wally Feurzeig, Seymour Papert, and Cynthia Solomon. Logo is not an acronym: the name was coined by Feurzeig while he was at Bolt, Beranek and Newman, and derives from the Greek logos, meaning word or thought.

Interactive Turtle is an implementation of Logo programming language as a Jupyter Widget for Jupyter Lab. Interactive Turtle is a popular way for introducing programming to kids and beginners.

Imagine a robotic turtle starting at the middle of the coordinate plane. After an from iturtle import Turtle and creating instance t = Turtle(), give it the command t.forward(15), and it moves 15 pixels in the direction it is facing, drawing a line as it moves. Give it the command t.right(25), and it rotates in-place 25 degrees clockwise.

By combining together these and similar commands, intricate shapes and pictures can easily be drawn.

For example, intricate shapes can be drawn by repeating simple moves:

from iturtle import Turtle

turtle = Turtle()
turtle.pencolor("gold")

for i in range(36):
    turtle.forward(300)
    turtle.left(170)

Please check the following samples:

Currently Interactive Turtle supports these methods:

Turtle motion

home()

Move turtle to the origin – by default the middle of the coordinate plane – and set its heading to its start-orientation which is to the right (east).

turtle.home()

forward()

Move the turtle forward by the specified distance, in the direction the turtle is headed.

turtle.forward(20)

Move the turtle backward by the specified distance, in the direction the turtle is headed.

turtle.backward(20)

left()

Turn turtle left by angle units. Units are by default degrees.

turtle.left(90)

right()

Turn turtle right by angle units. Units are by default degrees.

turtle.right(90)

speed()

Set the turtle’s speed to an integer value in the range 0..10.

Speeds from 1 to 10 enforce increasingly faster animation of line drawing and turtle turning.

turtle.speed(1)

Pen control

penup()

Pull the pen up – no drawing when moving.

turtle.penup()

pendown()

Pull the pen down – drawing when moving.

turtle.pendown()

pencolor()

Set the color of the pen.

You can set pen color to color string, which is a color specification string, such as "red", "yellow", or "#33cc8c".

turtle.pencolor("red")

You can also set pen color to the RGB color represented by r, g, and b. Each of r, g, and b must be in the range 0..255.

turtle.pencolor(255, 255, 255)

bgcolor()

Set background color of the turtle canvas.

You can set background color to color string, which is a color specification string, such as "red", "yellow", or "#33cc8c".

turtle.bgcolor("black")

Development Installation

Create a dev environment:

conda env create -f environment.yml

Install the python. This will also build the TS package.

pip install -e ".[test, examples]"

When developing your extensions, you need to manually enable your extensions with the lab frontend. For lab, this is done by the command:

jupyter labextension develop --overwrite .
yarn run build

How to see your changes

If you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the widget.

Watch the source directory in one terminal, automatically rebuilding when needed:

yarn run watch

Run JupyterLab in another terminal:

jupyter lab --no-browser

After a change wait for the build to finish and then refresh your browser and the changes should take effect.

If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

iturtle-0.1.4-py2.py3-none-any.whl (355.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file iturtle-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: iturtle-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 355.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for iturtle-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a3cb74d698459b447f41e5eaabb0de2348377ce6f2eb91930cd232b019e1ea7d
MD5 07ac7267155a4fba2ec33aa857fc7dc9
BLAKE2b-256 bdd2eb90893f09e2518a4fca52d248f0a4cabe9630f4028929153ec89c98422e

See more details on using hashes here.

Provenance

Supported by

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