Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make turtle graphics inline

I have been using turtle package in python idle. Now I have switched to using Jupyter notebook. How can I make turtle inline instead of opening a separate graphic screen. I am totally clueless about. Any pointers and advice will be highly appreciated.

like image 743
dearbharat Avatar asked Jan 21 '17 10:01

dearbharat


People also ask

How do you make a dashed line on a turtle?

Drawing a dashed lineYou can move the turtle without the turtle drawing its movement by using the turtle. penup() function; to tell it to draw again, use turtle. pendown() .

How do you move graphics on a turtle?

We can use the forward() function to make the turtle move forward, or the backward() function to make the turtle move backward. These commands also have shortcuts of fd() for forward(), or bk() for backward().


3 Answers

I found the following library that has a Turtle implementation working in Jupyter notebooks: https://github.com/takluyver/mobilechelonian

like image 65
marco Avatar answered Oct 26 '22 20:10

marco


With python3.6+:

python -m pip install ipyturtle3

Try the examples listed in this repo: https://github.com/williamnavaraj/ipyturtle3

https://pypi.org/project/ipyturtle3/

I found this to work in JupyterLab and VSCode

like image 2
William Avatar answered Oct 26 '22 19:10

William


I am a windows user, so run the CMD as an administrator and run this:

jupyter nbextension enable --py --sys-prefix ipyturtle

Run the above after installing the ipyturtle

pip3 install ipyturtle
like image 1
Denzel Akwanie Avatar answered Oct 26 '22 21:10

Denzel Akwanie