from tkinter import *
import os
from PIL import Image, ImageTk
def getFileName(image):
print(str(image))
def CropManual():
global outputFile
#getCrop(outputFile)
print("Crop Manual")
def showImages(folder):
print("loading....", folder)
gtk = Tk()
gtk.wm_title("Images")
row, col = 0,0
for images in os.listdir(folder):
if not images.lower().endswith(('.png', '.jpg', '.jpeg')):
continue
print(images)
im = Image.open(os.path.join(folder, images))
im = im.resize((250, 250), Image.LANCZOS)
tkimage = ImageTk.PhotoImage(im)
handler = lambda img = images : getFileName(img)
imageButton = Button(gtk, image=tkimage, command=handler)
imageButton.image=tkimage
imageButton.grid(row=row+1, column=col+1, padx=3, pady=3)
row +=1; col+=1;
userCrop = Button(gtk, text="Crop Manually?", command=CropManual)
userCrop.grid(row=row+1, column=col+1, padx=3, pady=3)
gtk.mainloop()
showImages(r"ที่อยู่โฟลเดอร์แบบเต็ม")