Aug-02-2020, 10:35 AM
Hi,
i have five labels with a Photo in a frame:
So i tried to get the parent label of the image to set the new image onto like this:
So:
- Is this function not impelemented, why?
- how can i get the parent of the image?
- is there another way to zoom such images?
i have five labels with a Photo in a frame:
for entry in dir: file = self.file_path + "\\" + entry if os.path.isfile(file): try: label = tk.Label(self.inner, text=location_date_str + entry) label.pack(side="top", anchor=tk.NW, pady=(10, 0)) image = ImageTk.PhotoImage(Image.open(file)) image_label = tk.Label(self.inner, image=image) self.photos.insert(0, image) # to prevent garbage collector from remove... image_label.pack(side="top", anchor=tk.NW) except: tk.messagebox.showinfo(title="Exception", message=traceback.format_exc())Now to zoom in and out i guess that i can't just change the image, because the new image would not have the same reference as the old one and therefore the label wouldn't get the new but hold the old one.
So i tried to get the parent label of the image to set the new image onto like this:
def zoom_in(self, event=None): print("zoom in") for image in self.photos: # get the parent (label) of the image label = image.winfo_parent() # get a zoomed image image = image._PhotoImage__photo.zoom(2) label.config(image=image)Error message: 'PhotoImage' object has no attribute 'winfo_parent'
So:
- Is this function not impelemented, why?
- how can i get the parent of the image?
- is there another way to zoom such images?