我設計了一個可以旋轉的弧線,但我無法弄清楚爲什麼IDLE告訴我在我的代碼中仍然存在錯誤。Python Tkinter TclError
這裏是我的代碼:
from Tkinter import*
from math import *
from time import sleep
pai=Tk()
cv=Canvas(pai,width=1100,height=631,bg="white")
cv.pack()
bb=(150,110,550,510)
temp1=0
temp2=24
t=0
arc1=cv.create_arc(bb,start=temp1,extent=temp2,fill="yellow")
while True:
t=0.51
temp1+=t
cv.itemconfig(arc1,start=temp1)
cv.update()
這是results:
Traceback (most recent call last):
File "C:\Users\amazi\Desktop\作業\s.py", line 15, in <module>
cv.itemconfig(arc1,start=temp1)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 2408, in itemconfigure
return self._configure(('itemconfigure', tagOrId), cnf, kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1321, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
TclError: invalid command name ".93591304L"
不重視代碼的圖像。將它放在這裏 –
使用'tkintet.after()'而不是'while' – furas
'IDLE'是用'tkinter'構建的,所以有時候會導致使用'tkinter'的代碼出現問題。在console/terminal/cmd.exe中運行代碼進行測試。 – furas