0
私は取得しています、次のエラー:_tkinter.TclError:無効なコマンド名が」0.14574424"
_tkinter.TclError: invalid command name “.14574424”
私は、エラーを理解することはできませんよ。私は間違って何をしていますか?
# Import tkinter
from tkinter import *
class AnimationDemo:
def __init__(self):
window = Tk() # Create a window
window.title("Animation Demo") # Set a title
width = 250 # Width of the canvas
canvas = Canvas(window, bg = "white", width = 250, height = 50)
canvas.pack()
x = 0 # Starting x position
canvas.create_text(x, 30, text = "Message moving?", tags = "text")
dx = 3
while True:
canvas.move("text", dx, 0) # Move text dx unit
canvas.after(100) # Sleep for 100 milliseconds
canvas.update() # Update canvas
if x < width:
x += dx # Get the current position for string
else:
x = 0 # Reset string position to the beginning
canvas.delete("text")
# Redraw text at the beginning
canvas.create_text(x, 30, text = "Message moving?", tags = "text")
window.mainloop() # Create an event loop
AnimationDemo() # Create GUI
エラー:トレースバック(最新の呼び出しの最後): ファイル「Dを:/sem4/t/lesson4/task1/task.py "、行29、 AnimationDemo()#GUIの作成 ファイル「D:/sem4/t/lesson4/task1/task.py」17行目__init__ canvas.move( "text"、dx、0)#移動テキストのDX単位 F ile "C:¥Users¥sreeyu¥AppData¥Local¥Programs¥Python¥Python35¥lib¥tkinter¥__ init__.py"、2431行目移動中 self.tk.call((self._w、 'move')+ args) _tkinter.TclError:無効なコマンド名 ".14440096" –
hss
何が原因でエラーが発生していますか?ところで、これはTkinterでアニメーションを行うには間違った方法です。 http://stackoverflow.com/a/11505034/7432 –
を参照してくださいありがとう@BryanOakleyしかし私は私たちがループ中に使用した場合、それがエラーを表示していた理由を知っているかもしれません – hss