0
我有一些代碼,但不斷收到此錯誤讓龜改變自己的形象
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 686, in eventfun
fun()
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\RPG.py", line 21, in up
combat()
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\RPG.py", line 58, in combat
enemy.shape(image)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 2777, in shape
self.turtle._setshape(name)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 2506, in _setshape
self._item = screen._createimage(screen._shapes["blank"]._data)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 723, in _createimage
return self.cv.create_image(0, 0, image=image)
File "<string>", line 1, in create_image
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 2483, in create_image
return self._create('image', args, kw)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 2474, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: image "pyimage1" doesn't exist
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 686, in eventfun
fun()
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\RPG.py", line 21, in up
combat()
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\RPG.py", line 58, in combat
enemy.shape(image)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 2777, in shape
self.turtle._setshape(name)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 2506, in _setshape
self._item = screen._createimage(screen._shapes["blank"]._data)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\turtle.py", line 723, in _createimage
return self.cv.create_image(0, 0, image=image)
File "<string>", line 1, in create_image
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 2483, in create_image
return self._create('image', args, kw)
File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 2474, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: image "pyimage1" doesn't exist
我到simplist程度代碼
import os
from turtle import Turtle,Screen
print(os.getcwd())
os.chdir('C:\\Users\\Travi\\Downloads')
print(os.getcwd())
screen.register_shape("Crawfish_attack.gif")
Turtle.shape("Crawfish_attack.gif")
謝謝你,它的工作,現在我想通了,我需要做更多的工作,我的工作代碼 – Travis