问题描述
我无法放大照片并放入标签中。
def displayimage(self,_event=None):
if self.videopath != "" and self.txtsequenceframe.get() != "":
# Placing the lable in a different location at runtime
self.photodisplay.place(width=700,height=500,x=0,y=0)
self.currentphoto = Image.open(self.framepaths[int(self.txtsequenceframe.get())])
self.currentphoto.resize((700,500),Image.ANTIALIAS)
self.currentphotoready = ImageTk.PhotoImage(self.currentphoto)
self.photodisplay.config(image=self.currentphotoready)
我已经搜索了这个主题,但是他们创建了一个新标签并将图像放置在那里。实际上,我想多次更改该图像。有人可以帮我解决这个错误吗?
解决方法
def displayimage(self,_event=None):
if self.videopath != "" and self.txtsequenceframe.get() != "":
# Placing the lable in a different location at runtime
self.photodisplay.place(width=700,height=500,x=0,y=0)
self.currentphoto = Image.open(self.framepaths[int(self.txtsequenceframe.get())])
self.currentphoto = self.currentphoto.resize((700,500),Image.ANTIALIAS)
self.currentphotoready = ImageTk.PhotoImage(self.currentphoto)
self.photodisplay.config(image=self.currentphotoready)
这是正确的代码。我误将调整大小的图像存储在第6行。