Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant Add Shape (image)

I am trying to add a image to my code but it keep raising the error

Bad arguments for register_shape

I am following the tutorial at http://blog.trinket.io/using-images-in-turtle-programs/

my code is:

import turtle

screen = turtle.Screen()

# click the image icon in the top right of the code window to see
# which images are available in this trinket
image = "C:\...\rocketship.png"

# add the shape first then set the turtle shape
screen.addshape(image)
turtle.shape(image)

I am using python 2.6. furthermore when I use the function of

screen.bgpic("C:...\Backgrounds\giphy2.gif")

The background works.

like image 573
Liron Lavi Avatar asked Sep 03 '25 04:09

Liron Lavi


1 Answers

You may look for answers here: How can i add an image (Python)

The turtle module does have support for images, but only GIF images, not PNG or any other format. As the docs for addshape say:

name is the name of a gif-file and shape is None: Install the corresponding image shape.

like image 140
eaglebrain Avatar answered Sep 04 '25 17:09

eaglebrain