Skip to content Skip to sidebar Skip to footer

How Can I Import An Image In Python Turtle?

What I want, is to get an image to replace the default turtle, just like it is done here: http://blog.trinket.io/using-images-in-turtle-programs/ . This is my code, but I don't kno

Solution 1:

The turtle graphics has support for .gif images only. Please try to change your image's format.

Here's a link to a similar question How can i add an image (Python)

Solution 2:

You can take screenshot of the pic and can convert/resize to .gif at ezgif.com.

Background:

win = turtle.Screen()
win.bgpic('background.gif') or whatever the file name in the directory.

Using Shapes:

win.register_shape('pic1.gif')
rocket = turtle.Turtle()
rocket.shape('pic1.gif')

Simple example game:

https://www.youtube.com/watch?v=sRnSJvSHgBs&t=4s

Solution 3:

Trinket is a program for python! You have to type your code in trinket if you want that code to work!

Solution 4:

this picture must be in the same folder with doc.py . And then you can write name of the picture: img.gif

Post a Comment for "How Can I Import An Image In Python Turtle?"