You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for other image formats(e.g. PNG) to the turtle module #95371
Add support for PGM, PPM, and PNG formats to turtle.bgpic() and turtle.register_shape().
Pitch
Currently, turtle only supports GIF format for an image file,
where as the backend tkinter.PhotoImage supports PGM, PPM, and PNG formats in addition to GIF format.
If turtle supports PNG format, you can animate true color images.
(It helps teaching Python with turtle, because you can search PNG images more easily than GIF ones on Internet.)
Also it would be consistent if turtle supports all formats that tkinter supports.
Thanks hugovk, you are fast. I was working on a PR when you posted. My approach for register_shape coincides with your second one.
You may ignore my PR if you are working on your own PR.
Activity
hugovk commentedon Jul 28, 2022
Testing with Python 3.11,
bgpicalready accepts a PGM, PPM and PNG (but docs would need to be updated):Testing
register_shape:Works with a change something like this (plus docs would need updating):
Alternatively, the extension check could be removed, and just let tkinter handle it, as is the case with
bgpic:pythongh-95371: Add support for other image formats(e.g. PNG) to the …
relent95 commentedon Jul 28, 2022
Thanks hugovk, you are fast. I was working on a PR when you posted. My approach for register_shape coincides with your second one.
You may ignore my PR if you are working on your own PR.
relent95 commentedon Feb 3, 2023
Can anyone review the above PR? Because its base version is quite old, I can prepare a new PR if it's required.
gh-95371: Add support for other image formats(e.g. PNG) to the turtle… (
pythongh-95371: Add support for other image formats(e.g. PNG) to the …