Is it possible to know what shapes are currently available?

Asked

Viewed 66 times

1

I’m using the module turtle of Python and would like to know if there is a way to know what the types of Shape that the turtle can assume. I know that one can create or add more shapes to the dictionary of TurtleScreen, but I honestly haven’t had time to read all the documentationand I’m not sure what she was talking about at the time.

1 answer

1


In accordance with the documentation (my emphasis):

turtle.shape(name=None)

Parameters: name - a string that is a valid form name

Makes the shape of the turtle to be the one with the given name or, if the name was not given, returns the name of the current form. A form with the name name needs to exist in the form dictionary of TurtleScreen. Initially there are the following polygonal forms: "arrow", "turtle", "circle", "square", "triangle", "classic. To learn how to deal with forms see the method of Screen register_shape().

Updating: to get a list of names of the supported forms - both the standard ones and the ones added by the programmer - dynamically, you can use the method getshapes of TurtleScreen:

>>> Screen().getshapes()
['arrow', 'blank', 'circle', 'classic', 'square', 'triangle', 'turtle']

Note: I don’t know if this is the best way to get an instance of TurtleScreen, because I’m a beginner in this library.

  • @Cell It is because I am the author of the post (reply) and therefore I am automatically notified of any comment in it - whether it addressed to me or not. Similarly, I can’t "tag you" on the question, because you’re her author.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.