0
私はPythonのTurtle Graphicsを使用しています。背景の画像を設定したいと思います。しかし、それは動作していません。明日のコンピュータサイエンスクラスの課題があるので、私はすぐに答えが必要です。> _ <。ここに私のコードは次のとおりです。Python - 'bgpic'が動作しない
import time
import sys
import turtle
##Render
turtle.bgpic("background.png")
##End
turtle.done()
そして、私はこのエラーを取得しています:
応答しない画面に続いTraceback (most recent call last):
File "C:/Users/Alfie/Desktop/Youtube Game/Youtube.py", line 6, in <module>
turtle.bgpic("background.png")
File "<string>", line 8, in bgpic
File "C:\Python27\lib\lib-tk\turtle.py", line 1397, in bgpic
self._bgpics[picname] = self._image(picname)
File "C:\Python27\lib\lib-tk\turtle.py", line 503, in _image
return TK.PhotoImage(file=filename)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 3366, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 3320, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: couldn't recognize data in image file "background.png"
。誰がエラーが何であるか知っていますか?
実際、タートルパッケージのドキュメントでは、[.bgpic](https://docs.python.org/2/library/turtle.html#turtle.bgpic)のバックグラウンドの.gifイメージしかサポートしていないと主張しています。 –
ありがとうございます<3しよう! –