Python 2.7 异常属性错误:当我试图让Tkinter刷新图像时

Python 2.7 异常属性错误:当我试图让Tkinter刷新图像时,python-2.7,tkinter,Python 2.7,Tkinter,我是Tkinter的新手,但我希望每5秒刷新一次jpg图像,我已经编写了这段代码,但是我得到了一个异常属性错误。 有人能指引我吗 我收到这个错误: Exception AttributeError: "'PhotoImage' object has no attribute '_PhotoImage__ph oto'" in <bound method PhotoImage.__del__ of <PIL.ImageTk.PhotoImage object at 0 x754b16f

我是Tkinter的新手,但我希望每5秒刷新一次jpg图像,我已经编写了这段代码,但是我得到了一个异常属性错误。 有人能指引我吗

我收到这个错误:

Exception AttributeError: "'PhotoImage' object has no attribute '_PhotoImage__ph
oto'" in <bound method PhotoImage.__del__ of <PIL.ImageTk.PhotoImage object at 0
x754b16f0>> ignored


# -*- coding: utf-8 -*-
from Tkinter import *

from apscheduler.schedulers.background import BackgroundScheduler
from PIL import ImageTk, Image
import time

window = Tk()
scheduler = BackgroundScheduler()
a = 0

def readimage():
        global a, img, img1, img2, imglab
        a = a +1
        img = Image.open("./web1.jpg")
        img1 = img.resize((288, 162), Image.ANTIALIAS)
        img2 = ImageTk.PhotoImage(img1)

readimage()

window.attributes('-fullscreen', True)
window.configure(background = "black")
endbutton = Button(window, text="exit", command=window.destroy)
endbutton.grid(row=1,column=1, sticky="nw")
alabel = Label(window, text=a)
alabel.grid(row=2, column=2, sticky="w")
imglab = Label(window, image=img2, bg="black",fg="white",  font=("Arial", 18))

imglab.place(relx=.6, rely=1.0,anchor="sw")
imglab.lower()

window.update()

scheduler.add_job(readimage, 'interval', seconds=5)
scheduler.start()
while True:
        time.sleep(1)
        alabel[ "text"]=a
        imglab[ "image"]=img2
        window.update()

mainloop()
异常属性错误:“'PhotoImage'对象没有属性'\u PhotoImage\u
被忽视的“奥托”
#-*-编码:utf-8-*-
从Tkinter进口*
从apscheduler.schedulers.background导入BackgroundScheduler
从PIL导入ImageTk,图像
导入时间
window=Tk()
调度程序=背景调度程序()
a=0
def readimage():
全局a、img、img1、img2、imglab
a=a+1
img=Image.open(“./web1.jpg”)
img1=img.resize((288162),Image.ANTIALIAS)
img2=ImageTk.PhotoImage(img1)
readimage()
属性('-fullscreen',True)
window.configure(background=“black”)
endbutton=按钮(窗口,text=“退出”,命令=窗口。销毁)
endbutton.grid(行=1,列=1,sticky=“nw”)
阿拉贝尔=标签(窗口,文本=a)
阿拉贝尔网格(行=2,列=2,sticky=“w”)
imglab=标签(窗口,图像=img2,bg=“黑色”,fg=“白色”,font=(“Arial”,18))
imglab.place(relx=0.6,rely=1.0,anchor=“sw”)
imglab.lower()
window.update()
计划程序.添加作业(readimage,'间隔',秒=5)
scheduler.start()
尽管如此:
时间。睡眠(1)
阿拉贝尔[“文本”]=a
imglab[“图像”]=img2
window.update()
mainloop()

请在问题中包含错误。是的,抱歉忘记:)已立即更新。请在问题中包含错误。是的,抱歉忘记:)已立即更新。