# 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": "https://files.pythonhosted.org/packages/82/4b/96657b93a3256bad3da6c463d67c39f1316dcff056606712f0f6eafb9c6f/iturtle-1.0.7.tar.gz",
"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.7",
"project_urls": {
"Homepage": "https://github.com/datarho/iturtle"
},
"split_keywords": [
"jupyter",
" widgets",
" ipython"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b684b59f3fe9e04d762a0afaf93797868f43ecfceb9e8b28b08eb6ae5d3c0abc",
"md5": "e5c7228f58b85b7628670151fe9db55a",
"sha256": "955c7a9e5ba11937a5ad28ca6aa8d1dd88f0fd62b8df30ec37e505376f2a5648"
},
"downloads": -1,
"filename": "iturtle-1.0.7-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "e5c7228f58b85b7628670151fe9db55a",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6",
"size": 898169,
"upload_time": "2024-11-26T05:39:15",
"upload_time_iso_8601": "2024-11-26T05:39:15.359673Z",
"url": "https://files.pythonhosted.org/packages/b6/84/b59f3fe9e04d762a0afaf93797868f43ecfceb9e8b28b08eb6ae5d3c0abc/iturtle-1.0.7-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "824b96657b93a3256bad3da6c463d67c39f1316dcff056606712f0f6eafb9c6f",
"md5": "6547661586d4300302d9da91aafd751a",
"sha256": "ce776aa12408ab79202e692ff329f1e6eaf50c1c8e5683751030b27ade477328"
},
"downloads": -1,
"filename": "iturtle-1.0.7.tar.gz",
"has_sig": false,
"md5_digest": "6547661586d4300302d9da91aafd751a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 663162,
"upload_time": "2024-11-26T05:39:16",
"upload_time_iso_8601": "2024-11-26T05:39:16.783320Z",
"url": "https://files.pythonhosted.org/packages/82/4b/96657b93a3256bad3da6c463d67c39f1316dcff056606712f0f6eafb9c6f/iturtle-1.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 05:39:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "datarho",
"github_project": "iturtle",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "iturtle"
}