Make turtle graphics inline
Asked Answered
B

3

10

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.

Bulletin answered 21/1, 2017 at 10:22 Comment(6)
turtle uses tkinter which can't run in Jupyter Notebook. Jupyter Notebook can display only HTML.Mousy
BTW: trinket.io can run turtle code in browser but it uses JavaScript to interpret Python code - so it may not work with Jupyter notebookMousy
Thank you so much for the answer. I have been thinking of developing teaching material for kids. Btw, where can I read and know more about package compatibility and capability.Bulletin
about "capability" of standard modules you can read in standard documentation: docs.python.org/3.5/library . Other modules should have own documentation in different places but Google should find it. About "compatibility" you can only find information if it compatible with Python 2 or/and Python 3. Most graphics modules and GUI aren't compatible with Jupyter because they use system elements to display graphics/widgets, they doesn't generate HTML/CSS/JavaScript.Mousy
BTW: materials (more or less) for kids: Program Arcade Games With Python And Pygame , Hour of Code , Hour of Code - Minecraft , Python Graphics.py module (it uses Tkinter in background) , Python and Minecraft, Python and Lego MindstormMousy
Thank you for your guidance and other resources for kids @furas. It is a great help. I will look at the documentation.Bulletin
B
3

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

Batter answered 16/7, 2018 at 21:52 Comment(2)
I did not try Jupyterlab. But it works fine in both the notebooks at jupyter.org and notebooks.azure.com (standard jupyter notebooks).Batter
I wonder how you made it work with azure notebooks, @marco. It does not seem to work for me (i.e. code executes, but turtle does not appear). Do I need to install some extension manually?Cheney
Y
3

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

Yockey answered 15/1, 2022 at 1:24 Comment(0)
R
1

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
Rosalia answered 5/9, 2020 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.