root = "./" img_file_paths = [] for path, subdirs, files in os.walk(root): for name in files: file_path = os.path.join(path, name) #neu open duoc file bang image, thi file do chinh la image, neu ko dc thi bo qua try: with Image.open(file_path) as im: img_file_paths.append(file_path) print(file_path, im.format, "%dx%d" % im.size, im.mode) except IOError: pass print(img_file_paths) g = Gui() canvas = g.ca(width=200, height=200) image_path = './python_mini.GIF' label1 = g.la(text=image_path) #show image to canvas image = Image.open(image_path) photo = ImageTk.PhotoImage(image) #convert to ImageTk myimg = canvas.image([0, 0], image=photo) #click event def callback(event): print("clicked at", event.x, event.y) global img_file_paths