_tkinter.TclError:图像“ .64485752”不存在

时间:2018-06-19 19:02:40

标签: python python-3.x

我写了一个重启程序,但是它不起作用

retry = Button(text="play again", width=11, bg="black", fg="grey99", command=restart)
retry.pack()

重启功能在下面

def restart():
    global window
    window.destroy()  # destroy and create a new one
    window = Tk()
    global screenheight
    global screenwidth
    screenwidth = window.winfo_screenwidth()
    screenheight = window.winfo_screenheight()
    window.geometry("{0}x{1}+0+0".format(window.winfo_screenwidth(), window.winfo_screenheight()))
    window.title("Predict future")
    canvas = Canvas(window, width=screenwidth, height=screenwidth, bg="ghost white")
    canvas.place(x=500, y=300)
    taiji = PhotoImage(file="taiji.gif")
    taijitu = Label(image=taiji)
    intro = Button(window, image=taijitu, command=New)
    intro.place(x=-120, y=-60)

所以它只是破坏了旧的窗口并创建了一个新窗口,但是照片图像没有显示出来(我想它已经被垃圾收集了)。

0 个答案:

没有答案