-3
왜이 오류가 발생하는지 알지 못합니다. 정말 귀찮습니다. 나는이 오류가 발생합니다 :AttributeError : 'int'객체에 속성이 없습니다. Python
from tkinter import * import time
def movefigure(self, direction, ammount):
x = 0
y = 0
ammount2 = 0
if direction == "up":
print("Direction = " + ammount)
y = ammount
elif direction == "down":
print("Direction = " + ammount)
ammount2 = ammount - (ammount * 2)
y = ammount2
elif direction == "right" + ammount:
print("Direction = " + ammount)
x = ammount
elif direction == "left":
print("Direction = " + ammount)
ammount2 = ammount - (ammount * 2)
y = ammount2
canvas.move(self, x, y)
root = Tk()
root.title('Canvas')
tingx = 100
tingy = 100
tingxMove = 1
tingyMove = 1
canvas = Canvas(root, width=400, height=400)
ting = canvas.create_rectangle(205, 10, tingx, tingy, tags="Ting", outline='black', fill='gray50')
canvas.pack()
ting.movefigure(ting, "up", 20)
root.mainloop()
. movefigure는 별도의 메소드가 아닙니다. ting에 속하지 않습니다. –
args에서 자기가 첫 번째 객체 (팅아)를 취할 것이라고 생각했습니다. 어떻게해야합니까? – RasmusGP
그냥 ting을 제거하십시오. movefigure (ting, "up", 20)를 실행하십시오. –