1

I've read the answer here and still can't get a custom shape to work for Python Turtle.

My code is here:

import turtle

screen = turtle.Screen()
screen.register_shape('car', 'car.gif')

t = turtle.Turtle()
t.shape('car')

I'm getting AttributeError: 'str' object has no attribute '_type' but I don't know why. The image is a genuine .gif as required.

Any ideas please?

Robin Andrews
  • 3,514
  • 11
  • 43
  • 111

1 Answers1

1

You almost have it correct. When registering a polygon, you give it a name, but when registering a GIF image, you use the image's name:

import turtle

screen = turtle.Screen()
screen.register_shape('car.gif')

t = turtle.Turtle()
t.shape('car.gif')

screen.mainloop()
cdlane
  • 40,441
  • 5
  • 32
  • 81