1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| from tkinter import *
from PIL import Image, ImageTk
import os
import shutil
from functools import partial
folder_path = '/home/admin01/Images/test/'
directorysave= '/home/admin/Images/analyse'
x=0
y=0
imagelist=[] #tenter de créer une classe pour rendre ca plus propre
root = Tk()
vsb = Scrollbar(root, orient=VERTICAL)
vsb.grid(row=0, column=1, sticky=N+S)
hsb = Scrollbar(root, orient=HORIZONTAL)
hsb.grid(row=1, column=0, sticky=E+W)
c = Canvas(root,yscrollcommand=vsb.set, xscrollcommand=hsb.set)
c.grid(row=0, column=0, sticky="news")
vsb.config(command=c.yview)
hsb.config(command=c.xview)
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
fr = Frame(c)
check = IntVar()
def Trier():
print(check.get())
if(check.get() == 1):
print("check.get() = ", check.get())
#print(imagelist)
shutil.copy2(folder_path + file, directorysave+ "/photo/" + file)
print("copiée")
else:
print("pas copiée car check.get() = ", check.get())
#On ajoute des widgets :
for path, dirs, files in os.walk(folder_path):
resolution = (300,500)
for file in files:
canvas = Canvas(fr)
canvas.grid(row = x, column = y, sticky = N)
print(check.get())
image1 = Image.open(folder_path + file)
image1.thumbnail(resolution,Image.BILINEAR)
photo = ImageTk.PhotoImage(image1)
imagelist.append(photo)
Checkbutton(fr,variable=check,command = partial(Trier,file)).grid(row = x, column = y, sticky = S)
canvas.create_image(128,128, image=photo)
if(y<3):
y = y+1
else:
x = x+1
y = 0
print(file + " " + str(x) + " " +str(y))
if(y<3):
bouton=Button(fr, text="Terminer",anchor = SE, command= root.destroy)
bouton.grid(row = x, column = y+1)
else:
bouton=Button(fr, text="Terminer",anchor = SE, command= root.destroy)
bouton.grid(row = x+1, column = 0)
c.create_window(0, 0, window=fr)
fr.update_idletasks()
c.config(scrollregion=c.bbox("all"))
root.mainloop() |
Partager