4

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.

Liron Lavi
  • 421
  • 1
  • 5
  • 16
  • `r"C:\Users\--myName--\Desktop\Python\FinalPrj\Space\images\Backgrounds\giphy2.gif"` — add an `r` prefix. – martineau May 24 '15 at 18:15

1 Answers1

3

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.

Community
  • 1
  • 1
eaglebrain
  • 78
  • 1
  • 1
  • 8