hi: wuf
I tested the code, and it's worked with success.
could I ask you if it is possible to give a title (according to the name of the image) to the toplevel for each image that corresponds to it
I tried to give a title to the toplevel by modifying the function [def visualize(pil_images, index, event) ]like this:
thanks for your support
I tested the code, and it's worked with success.
could I ask you if it is possible to give a title (according to the name of the image) to the toplevel for each image that corresponds to it
I tried to give a title to the toplevel by modifying the function [def visualize(pil_images, index, event) ]like this:
def visualize(pil_images, index, event): zoom_fac = 4 pil_small_image = pil_images[index] image_size = pil_small_image.size zoomed_size = [int(side_width*zoom_fac) for side_width in image_size] pil_enlarged_image = pil_small_image.resize(zoomed_size) toplevel = Toplevel() #event.widget) toplevel.title("image " + str(index)) # title for toplevel toplevel.tk_enlarged_image = ImageTk.PhotoImage(pil_enlarged_image) Label(toplevel, image=toplevel.tk_enlarged_image).pack()and I modify the name of the pictures at the code like that :
image_path = "images/test" image_filenames = ("antennes.png", "far field.png", "unite de distribution.png", "unite de recombinaison.png") pil_images = list() tk_images = list() labels = list() for index, photo in enumerate(image_filenames): photo_name = "\n\n"+ str(image_filenames[index]) T_generalites_left.insert(END, photo_name,'style_loc35R') pil_image = Image.open(os.path.join(image_path, image_filenames[index])) pil_images.append(pil_image) tk_image = ImageTk.PhotoImage(pil_image) tk_images.append(tk_image) label = Label(T_generalites_left, image=tk_image, cursor='hand1') label.bind('<Button-1>', partial(visualize, pil_images, index)) T_generalites_left.window_create(END, window=label)I do not know if there is a better idea
thanks for your support