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
  • 2,901
  • 7
  • 33
  • 81

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
  • 37,186
  • 5
  • 26
  • 72