(python GUI)我认为这是一个有效的代码,但有一个语法错误

时间:2017-04-06 10:41:32

标签: python user-interface tkinter tkinter-canvas

我写了一个程序,将六边形形状移动了多次 第8行有一个错误,但我问你另一行是否有任何错误,

import time
from tkinter import*
tk = Tk()
canvas=Canvas(tk, width=1000, height=1000, background="black")
canvas.pack()
canvas.create_polygon(300,200,300,250,340,225,fill="yellow")

def TKUptake(CanvasMove(x),CanvasMove(y),CanvasMove(z)):
for x in range(0, 20):
    canvas.move(CanvasMove(x),CanvasMove(y),CanvasMove(z))
    tk.update()
    time.sleep(0.03)

k = int(input("input value"))
for q in range(0,k):    
   TKUptake(1,5,5)
   TKUptake(1,5,5)
   TKUptake(1,-5,5)
   TKUptake(1,-5,0)
   TKUptake(0,-5,-5)
   TKUptake(0,5,-5)

1 个答案:

答案 0 :(得分:0)

第8行有缩进错误,请使用以下

进行修复
def TKUptake(CanvasMove(x),CanvasMove(y),CanvasMove(z)):
    for x in range(0, 20):
        canvas.move(CanvasMove(x),CanvasMove(y),CanvasMove(z))
        tk.update()
        time.sleep(0.03)