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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| # -*- coding: utf-8 -*-
"""
Created on Wed Mar 7 19:41:14 2018
@author: Julien
"""
from tkinter import*
import PIL.Image
import PIL.ImageTk
import subprocess
from tkinter.filedialog import *
from PIL import ImageTk, Image
from PIL import ImageFilter
from numpy import sqrt
import sys
Largeur=600
Hauteur=360
algo=0
def algo1():
images=Image.open("titi.png")
imgF = images.filter(ImageFilter.CONTOUR) # algo qui isole les contours d'une image
imgF.save("tito.png")
algo=1
# Création de la fenêtre principale
Mafenetre=Tk()
Mafenetre.geometry("1300x600")
Mafenetre.title("photoALGO")
#-------------------------------#
# Création d'un widget Menu
menubar = Menu(Mafenetre)
menufichier = Menu(menubar,tearoff=0)
menubar.add_cascade(label="Fichier",command=Mafenetre.destroy)
#--------------------------------------------------------------#
# Affichage du menu
Mafenetre.config(menu=menubar)
#-----------------------------#
path = askopenfilename(filetypes=[('PNG FILES','*.png')])
print(path) #askopenfile pour ouvrir le fichier de son choix
photo = PIL.Image.open(path)
tailleL, tailleH = photo.size
print(int(tailleL))
print(tailleH)
# je resize l'image pour qu'elle rentre parfaitement dans mon canvas
resizetailleL=600/tailleL
resizetailleH=360/tailleH
newPhoto = photo.resize((int(tailleL*resizetailleL),int(tailleH*resizetailleH)))
newPhoto.save("titi.png")
Largeur=600
Hauteur=360
photos = PhotoImage(file="titi.png")
print(photos)
Can1=Canvas()
Can1.configure(width=Largeur, height=Hauteur) #Canvas avec l'image a modifier
image = Can1.create_image(0,0, image = photos, anchor='nw')
Can1.grid(row=0, column=0)
img = PhotoImage(file="blanc.png")
print(img)
cvs=Canvas()
cvs.configure(width=Largeur, height=Hauteur) #canvas avec une image blanche
images = cvs.create_image(600,0, image = img, anchor='ne')
cvs.grid(row=0, column=2)
#-----------------------------------------------------------------
#Bouton pour executer les algorithme
But=Button()
Button(Mafenetre, text ='Algo 2',width=10,height=4,command = algo1).grid(row=5, column=0,sticky='ne')
Button(Mafenetre, text ='Algo 3',width=10,height=4,command = Mafenetre.destroy).grid(row=5, column=1)
Button(Mafenetre, text ='Algo 4',width=10,height=4,command = Mafenetre.destroy).grid(row=5, column=2,sticky='nw')
But.grid()
#----------------------------------------------------------------------------------------------------#
Mafenetre.mainloop() |
Partager