5151 turtle. So the turtles can more easily be used as a visual feedback
5252 instrument by the (beginning) programmer.
5353
54- - Different turtle shapes, gif-images as turtle shapes, user defined
54+ - Different turtle shapes, image files as turtle shapes, user defined
5555 and user controllable turtle shapes, among them compound
5656 (multicolored) shapes. Turtle shapes can be stretched and tilted, which
5757 makes turtles very versatile geometrical objects.
@@ -468,7 +468,7 @@ def _blankimage(self):
468468
469469 def _image (self , filename ):
470470 """return an image object containing the
471- imagedata from a gif- file named filename.
471+ imagedata from an image file named filename.
472472 """
473473 return TK .PhotoImage (file = filename , master = self .cv )
474474
@@ -872,10 +872,7 @@ def __init__(self, type_, data=None):
872872 if isinstance (data , list ):
873873 data = tuple (data )
874874 elif type_ == "image" :
875- if isinstance (data , str ):
876- if data .lower ().endswith (".gif" ) and isfile (data ):
877- data = TurtleScreen ._image (data )
878- # else data assumed to be PhotoImage
875+ assert (isinstance (data , TK .PhotoImage ))
879876 elif type_ == "compound" :
880877 data = []
881878 else :
@@ -1100,14 +1097,18 @@ def register_shape(self, name, shape=None):
11001097 """Adds a turtle shape to TurtleScreen's shapelist.
11011098
11021099 Arguments:
1103- (1) name is the name of a gif- file and shape is None.
1100+ (1) name is the name of an image file (PNG, GIF, PGM, and PPM) and shape is None.
11041101 Installs the corresponding image shape.
11051102 !! Image-shapes DO NOT rotate when turning the turtle,
11061103 !! so they do not display the heading of the turtle!
1107- (2) name is an arbitrary string and shape is a tuple
1104+ (2) name is an arbitrary string and shape is the name of an image file (PNG, GIF, PGM, and PPM).
1105+ Installs the corresponding image shape.
1106+ !! Image-shapes DO NOT rotate when turning the turtle,
1107+ !! so they do not display the heading of the turtle!
1108+ (3) name is an arbitrary string and shape is a tuple
11081109 of pairs of coordinates. Installs the corresponding
11091110 polygon shape
1110- (3 ) name is an arbitrary string and shape is a
1111+ (4 ) name is an arbitrary string and shape is a
11111112 (compound) Shape object. Installs the corresponding
11121113 compound shape.
11131114 To use a shape, you have to issue the command shape(shapename).
@@ -1120,12 +1121,9 @@ def register_shape(self, name, shape=None):
11201121
11211122 """
11221123 if shape is None :
1123- # image
1124- if name .lower ().endswith (".gif" ):
1125- shape = Shape ("image" , self ._image (name ))
1126- else :
1127- raise TurtleGraphicsError ("Bad arguments for register_shape.\n "
1128- + "Use help(register_shape)" )
1124+ shape = Shape ("image" , self ._image (name ))
1125+ elif isinstance (shape , str ):
1126+ shape = Shape ("image" , self ._image (shape ))
11291127 elif isinstance (shape , tuple ):
11301128 shape = Shape ("polygon" , shape )
11311129 ## else shape assumed to be Shape-instance
@@ -1454,7 +1452,7 @@ def bgpic(self, picname=None):
14541452 """Set background image or return name of current backgroundimage.
14551453
14561454 Optional argument:
1457- picname -- a string, name of a gif- file or "nopic".
1455+ picname -- a string, name of an image file (PNG, GIF, PGM, and PPM) or "nopic".
14581456
14591457 If picname is a filename, set the corresponding image as background.
14601458 If picname is "nopic", delete backgroundimage, if present.
0 commit comments