为什么我会遇到“错误的窗口路径名称”问题

问题描述 投票:0回答:1

我有这个代码 现在我知道问题是因为我正在使用 delted 对象,但我可以看到在哪里,因为我不知道再次使用 deletd 对象的函数 食品标签 是玩家 我想要它,所以当拍摄对象具有与“僵尸”相同的x时 僵尸消失了,但我遇到了“错误的窗口路径名”问题

欢迎任何帮助,谢谢 射击(事件): 如果得分 < 200: global way way = canvas.create_line(Food.label.winfo_x() + 20, Food.label.winfo_y() + 40,Food.label.winfo_x() + 65, Food.label.winfo_y() + 40, fill="yellow", width=5, tags=("line1"))

print(Food.label.winfo_x()+5)
print("ggffedg")
print(canvas.coords(way))
global list2
list2 = canvas.coords(way)
print(list2[1])
if list2[2] <= 1450 and scor < 200:
    while list2[2] <= 1450:
        print(list2[2])
        print("d")

        print("hellllo")
        





        canvas.coords(way,list2[0] +100,list2[1],list2[2]+100,list2[3])
        list2[0] = list2[0] + 0.05
        list2[1] = list2[1]
        list2[2] = list2[2] + 0.05
        list2[3] = list2[3]
        print(list2)
        if list3[0] >= list2[2]>list3[0]-1:
            print("f")
            parent1.delete(w)

            parent1.destroy()

        wind.update()










        if list2[2] >= 1450:
            canvas.itemconfig(way, fill='white')
if scor > 200:
    print("132")

    way = canvas.create_line(Food.label.winfo_x() + 20, Food.label.winfo_y() + 40,Food.label.winfo_x() + 65,              
                             Food.label.winfo_y() + 40, fill="blue", width=5, tags=("line1"))
    list2 = canvas.coords(way)
    if list2[2] <= 1450:
        while list2[2] <= 1450:
            print("hellllo")
            

            canvas.coords(way, list2[0] + 100, list2[1], list2[2] + 100, list2[3])
            list2[0] = list2[0] + 0.05
            list2[1] = list2[1]
            list2[2] = list2[2] + 0.05
            list2[3] = list2[3]
            print(list2)

            wind.update()
            if list2[2] >= 1450:
                canvas.itemconfig(way, fill='white')

def hzom():
    global parent1
    parent1 = Canvas(wind, width=50, height=50)
    global oval12
    global w
    w = parent1.create_oval(0, 0, 50, 50, fill="blue", tags=("oval12",))
    global list3
    list3 = [1300, 640]
    parent1.place(x=list3[0], y=list3[1])
    print("d")

def zombie():
    if list3[0] >= Food.label.winfo_x():
        while list3[0] >= Food.label.winfo_x():

            list3[0] = list3[0] - 0.05

            parent1.place(x=list3[0], y=list3[1])

            #print(list3[0])
            #print(list3[1])
            wind.update()

    if list3[0] <= Food.label.winfo_x():
        while list3[0] <= Food.label.winfo_x():
            #print(list3[0])
            #print(list3[1])

            list3[0] = list3[0] + 0.05

            parent1.place(x=list3[0],y=list3[1])
            wind.update()



print(Food.label.winfo_y())



wind.bind("<e>", shoot)

wind.bind("<d>", move_right)
wind.bind("<a>", move_left)
wind.bind("<q>", move_up)
hzom()
Food()
zombie()




wind.mainloop()
python python-3.x tkinter tkinter-canvas
1个回答
0
投票

在尝试在函数中访问Food.labelwind之前,请确保已正确初始化它们。

© www.soinside.com 2019 - 2024. All rights reserved.