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
|
from Tkinter import *
import Image
import ImageTk
# fonction qui ne servent qu'a appeller ChangeIm, apres il y aura un attribut
def img1():
changeIm()
def img3():
changeIm()
def img2():
changeIm()
# fonction sensé changer l'affichage de l'image. marche tres bien avec des gif sans PIL
def changeIm():
image=Image.open("test(3).jpg")
x,y=image.size
# on affiche une petit pop up pour dire que ca marche
fen2=Tk()
Label(fen2,text="salut").grid()
fen2.mainloop()
image=image.resize((400,300),Image.BICUBIC)
photo2=ImageTk.PhotoImage(image)
# on change l'image affiché
can1.itemconfigure(item ,image=photo2)
# creation de la fenetre principale
fen=Tk()
fen.title("Futur outil de visualisation")
#différents textes
lab1=Label(fen,text='Anglais')
lab1.grid(row=0,column=0)
Label(fen,text='عربÙ').grid(row=0,column=2)
Label(fen,text='Site Name').grid(row=1,column=0)
Label(fen,text='اسÙ
اÙÙ
ÙÙØ¹').grid(row=1,column=2)
item=''
c=0
while c<6:
Label(fen, text='Field '+str(c+1)+' = sth', bg="white").grid(row= c+3,column=0)
c=c+1
c=0
while c<6:
Label(fen, text='Ø´ÙØ¡ '+str(c+1)+' = اÙÙ
ÙØ§Ø¯ÙÙ', bg="white").grid(row=c+3,column=2)
c=c+1
# bouton d'appel du changement d'image
but1=Button(fen,text="Photo 1 - 1 ØµÙØ±",command=img1)
but1.grid(row=9, column=0)
but2=Button(fen,text="Photo 2 - 2 ØµÙØ±",command=img2).grid(row=9, column=1)
but3=Button(fen,text="Photo 3 - 3 ØµÙØ±",command=img3).grid(row=9, column=2)
#creation du canvas de l'image
can1 = Canvas(fen,bg='dark grey',height=300, width=400)
image=Image.open('test(15).jpg')
x,y=image.size
image=image.resize((400,300),Image.BICUBIC)
photo2=ImageTk.PhotoImage(image)
##photo2=PhotoImage(file="test(3).gif")
item = can1.create_image(200,150, image =photo2)
can1.grid(row=10, rowspan=5,columnspan=3)
but4=Button(fen,text="Quitter - Ø§ÙØ³Ø*بت", command=fen.quit).grid(row=16, column=1)
fen.mainloop()
fen.destroy() |
Partager