iturtle


Nameiturtle JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/datarho/iturtle
SummaryA Custom Jupyter Widget Library
upload_time2024-05-08 03:18:51
maintainerNone
docs_urlNone
authorSamuel Zhang
requires_python>=3.6
licenseMIT
keywords jupyter widgets ipython
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Interactive Turtle

[![Build Status](https://travis-ci.org/datarho.tech/iturtle.svg?branch=master)](https://travis-ci.org/datarho.tech/iturtle)
[![codecov](https://codecov.io/gh/datarho.tech/iturtle/branch/master/graph/badge.svg)](https://codecov.io/gh/datarho.tech/iturtle)

A custom Jupyter widget for interactive turtle.

## Installation

You can install using `pip`:

```bash
pip install iturtle
```

Here is the suggested conda environment:

```bash
conda create -n turtle -c conda-forge python=3.10 jupyterlab=3.5
```

## 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)
```

![](star.svg)

Please check the following samples:

- [Introduction](examples/introduction.ipynb)
- [Star](examples/star.ipynb)
- [Spiral](examples/spiral.ipynb)

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()` or `fd()`

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

```
turtle.forward(20)
```

`backward()` or `bk()`

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

```
turtle.backward(20)
```

`left()` or `lt()`

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

```
turtle.left(90)
```

`right()` or `rt()`

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()` or `pu()`

Pull the pen up – no drawing when moving.

```
turtle.penup()
```

`pendown()` or `pd()`

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")
```

`goto()`

Move turtle to an absolute position. If the pen is down, draw line. Do not change the turtle’s orientation.

```
turtle.goto(10, 10)
```

`teleport()`

Move turtle to an absolute position. Unlike `goto(x, y)`, a line will not be drawn. The turtle's orientation does not change.

```
turtle.teleport(20, 30)
```

## Development Installation

Create a dev environment:

```bash
conda env create -f environment.yml
```

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

```bash
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 .
jlpm 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:

```bash
jlpm run watch
```

Run JupyterLab in another terminal:

```bash
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/datarho/iturtle",
    "name": "iturtle",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "Jupyter, Widgets, IPython",
    "author": "Samuel Zhang",
    "author_email": "qizh@datarho.tech",
    "download_url": null,
    "platform": "Linux",
    "description": "# Interactive Turtle\n\n[![Build Status](https://travis-ci.org/datarho.tech/iturtle.svg?branch=master)](https://travis-ci.org/datarho.tech/iturtle)\n[![codecov](https://codecov.io/gh/datarho.tech/iturtle/branch/master/graph/badge.svg)](https://codecov.io/gh/datarho.tech/iturtle)\n\nA custom Jupyter widget for interactive turtle.\n\n## Installation\n\nYou can install using `pip`:\n\n```bash\npip install iturtle\n```\n\nHere is the suggested conda environment:\n\n```bash\nconda create -n turtle -c conda-forge python=3.10 jupyterlab=3.5\n```\n\n## Usage\n\nLogo 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.\n\nInteractive 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.\n\nImagine 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.\n\nBy combining together these and similar commands, intricate shapes and pictures can easily be drawn.\n\nFor example, intricate shapes can be drawn by repeating simple moves:\n\n```\nfrom iturtle import Turtle\n\nturtle = Turtle()\nturtle.pencolor(\"gold\")\n\nfor i in range(36):\n    turtle.forward(300)\n    turtle.left(170)\n```\n\n![](star.svg)\n\nPlease check the following samples:\n\n- [Introduction](examples/introduction.ipynb)\n- [Star](examples/star.ipynb)\n- [Spiral](examples/spiral.ipynb)\n\nCurrently Interactive Turtle supports these methods:\n\n### Turtle motion\n\n`home()`\n\nMove turtle to the origin \u2013 by default the middle of the coordinate plane \u2013 and set its heading to its start-orientation which is to the right (east).\n\n```\nturtle.home()\n```\n\n`forward()` or `fd()`\n\nMove the turtle forward by the specified distance, in the direction the turtle is headed.\n\n```\nturtle.forward(20)\n```\n\n`backward()` or `bk()`\n\nMove the turtle backward by the specified distance, in the direction the turtle is headed.\n\n```\nturtle.backward(20)\n```\n\n`left()` or `lt()`\n\nTurn turtle left by angle units. Units are by default degrees.\n\n```\nturtle.left(90)\n```\n\n`right()` or `rt()`\n\nTurn turtle right by angle units. Units are by default degrees.\n\n```\nturtle.right(90)\n```\n\n`speed()`\n\nSet the turtle\u2019s speed to an integer value in the range 0..10.\n\nSpeeds from `1` to `10` enforce increasingly faster animation of line drawing and turtle turning.\n\n```\nturtle.speed(1)\n```\n\n### Pen control\n\n`penup()` or `pu()`\n\nPull the pen up \u2013 no drawing when moving.\n\n```\nturtle.penup()\n```\n\n`pendown()` or `pd()`\n\nPull the pen down \u2013 drawing when moving.\n\n```\nturtle.pendown()\n```\n\n`pencolor()`\n\nSet the color of the pen.\n\nYou can set pen color to color string, which is a color specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n\n```\nturtle.pencolor(\"red\")\n```\n\nYou 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.\n\n```\nturtle.pencolor(255, 255, 255)\n```\n\n`bgcolor()`\n\nSet background color of the turtle canvas.\n\nYou can set background color to color string, which is a color specification string, such as \"red\", \"yellow\", or \"#33cc8c\".\n\n```\nturtle.bgcolor(\"black\")\n```\n\n`goto()`\n\nMove turtle to an absolute position. If the pen is down, draw line. Do not change the turtle\u2019s orientation.\n\n```\nturtle.goto(10, 10)\n```\n\n`teleport()`\n\nMove turtle to an absolute position. Unlike `goto(x, y)`, a line will not be drawn. The turtle's orientation does not change.\n\n```\nturtle.teleport(20, 30)\n```\n\n## Development Installation\n\nCreate a dev environment:\n\n```bash\nconda env create -f environment.yml\n```\n\nInstall the python. This will also build the TS package.\n\n```bash\npip install -e \".[test, examples]\"\n```\n\nWhen developing your extensions, you need to manually enable your extensions with the\nlab frontend. For lab, this is done by the command:\n\n```\njupyter labextension develop --overwrite .\njlpm run build\n```\n\n### How to see your changes\n\nIf you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different\nterminals to watch for changes in the extension's source and automatically rebuild the widget.\n\nWatch the source directory in one terminal, automatically rebuilding when needed:\n\n```bash\njlpm run watch\n```\n\nRun JupyterLab in another terminal:\n\n```bash\njupyter lab --no-browser\n```\n\nAfter a change wait for the build to finish and then refresh your browser and the changes should take effect.\n\nIf you make a change to the python code then you will need to restart the notebook kernel to have it take effect.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Custom Jupyter Widget Library",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/datarho/iturtle"
    },
    "split_keywords": [
        "jupyter",
        " widgets",
        " ipython"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bf154434c58931e56d0845b97e4452db34a4b5607a2858188d0969ffc31f32c",
                "md5": "da3f334d7a7a4c9d81bdce5179031a96",
                "sha256": "9982661ba1cc8a211ec11171c34b63089552397ad8b57e9f06680e4001c85e00"
            },
            "downloads": -1,
            "filename": "iturtle-1.0.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "da3f334d7a7a4c9d81bdce5179031a96",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 813902,
            "upload_time": "2024-05-08T03:18:51",
            "upload_time_iso_8601": "2024-05-08T03:18:51.756422Z",
            "url": "https://files.pythonhosted.org/packages/7b/f1/54434c58931e56d0845b97e4452db34a4b5607a2858188d0969ffc31f32c/iturtle-1.0.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-08 03:18:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datarho",
    "github_project": "iturtle",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "iturtle"
}
        
Elapsed time: 0.24700s