from Tkinter import * #boucle principale fenetre= Tk() fenetre.title("Interface graphique") fenetre.geometry("1440x950") fenetre['bg']='gray' imgNum = 10 def imagesuivante(): global xcan0, ycan0 ,xcan1, ycan1, imgNum ajout = 230 xcan1 = xcan1 + ajout #crée une nouvelle variable pour les images qui varient camera1.coords(imageCan1, xcan1, ycan1) camera1.coords(imageCan2, xcan1+ajout, ycan1) camera1.coords(imageCan3, xcan1+2*ajout, ycan1) camera1.coords(imageCan4, xcan1+3*ajout, ycan1) camera1.coords(imageCan5, xcan1+4*ajout, ycan1) camera1.coords(imageCan6, xcan1+5*ajout, ycan1) imgNum = imgNum + 1 imgName ='image%d.gif' photo0 = PhotoImage(file = imgName % imgNum) imageCan0 = camera1.create_image(xcan0, ycan1, image = photo0) camera1.coords(imageCan0, xcan1+(imgName-1)*ajout, ycan1) def imageprecedente(): global xcan1, ycan1 ajout = 230 xcan1 = xcan1 - ajout xcan2 = xcan1 + ajout xcan3 = xcan1 + 2*ajout xcan4 = xcan1 + 3*ajout xcan5 = xcan1 + 4*ajout xcan6 = xcan1 + 5*ajout camera1.coords(imageCan1, xcan1, ycan1) camera1.coords(imageCan2, xcan2, ycan1) camera1.coords(imageCan3, xcan3, ycan1) camera1.coords(imageCan4, xcan4, ycan1) camera1.coords(imageCan5, xcan5, ycan1) camera1.coords(imageCan6, xcan6, ycan1) def imagesuivante2(): global xcan2, ycan2 ajout = 230 xcan2 = xcan2 + ajout camera2.coords(imageCan7, xcan2, ycan2) camera2.coords(imageCan8, xcan2+ajout, ycan2) def imageprecedente2(): global xcan2, ycan2 ajout = 230 xcan2 = xcan2 - ajout xcan3 = xcan2 + ajout camera2.coords(imageCan7, xcan2, ycan2) camera2.coords(imageCan8, xcan3, ycan3) def imagesuivante3(): global xcan3, ycan3 ajout = 230 xcan3 = xcan3 + ajout camera3.coords(imageCan9, xcan3, ycan2) camera3.coords(imageCan10, xcan3+ajout, ycan2) def imageprecedente3(): global xcan3, ycan3 ajout = 230 xcan3 = xcan3 - ajout xcan4 = xcan3 + ajout camera3.coords(imageCan9, xcan3, ycan3) camera3.coords(imageCan10, xcan4, ycan3) #Nom des caméras Label(fenetre,text="Camera 1 ", bg='White').grid(row=1, column=1) Label(fenetre,text="Camera 2 ", bg='White').grid(row=4, column=1) Label(fenetre,text="Camera 3 ", bg='White').grid(row=7, column=1) #création des variables (globales) xcan0, ycan0 = 100, 85 xcan1, ycan1 = 100, 85 xcan2, ycan2 = 100, 85 xcan3, ycan3 = 100, 85 #Création des canevas camera1 = Canvas(fenetre, width =1350, height =195, bg ='white') camera1.grid(row =2, column =1) camera2 = Canvas(fenetre, width =1350, height =195, bg ='white') camera2.grid(row =5, column =1) camera3 = Canvas(fenetre, width =1350, height =195, bg ='white') camera3.grid(row =8, column =1) #Création des photos photo1 = PhotoImage(file ='image1.gif') imageCan1 = camera1.create_image(xcan1, ycan1, image = photo1) photo2 = PhotoImage(file ='image2.gif') imageCan2 = camera1.create_image(xcan1+230, ycan1, image = photo2) photo3 = PhotoImage(file ='image3.gif') imageCan3 = camera1.create_image(xcan1+460, ycan1, image = photo3) photo4 = PhotoImage(file ='image4.gif') imageCan4 = camera1.create_image(xcan1+690, ycan1, image = photo4) photo5 = PhotoImage(file ='image5.gif') imageCan5 = camera1.create_image(xcan1+920, ycan1, image = photo5) photo6 = PhotoImage(file ='image6.gif') imageCan6 = camera1.create_image(xcan1+1150, ycan1, image = photo6) photo7 = PhotoImage(file ='image7.gif') imageCan7 = camera2.create_image(xcan2, ycan2, image = photo7) photo8 = PhotoImage(file ='image8.gif') imageCan8 = camera2.create_image(xcan2+230, ycan2, image = photo8) photo9 = PhotoImage(file ='image9.gif') imageCan9 = camera3.create_image(xcan3, ycan3, image = photo9) photo10 = PhotoImage(file ='image10.gif') imageCan10 = camera3.create_image(xcan3+230, ycan3, image = photo10) #création des boutons suivant Boutonsuivant1 = Button(fenetre, text ='Images suivantes', bg = 'White', command = imagesuivante) Boutonsuivant1.grid(row =3, column = 1, sticky = E) Boutonsuivant2 = Button(fenetre, text ='Images suivantes', bg = 'White', command = imagesuivante2) Boutonsuivant2.grid(row =6, column = 1, sticky = E) Boutonsuivant3 = Button(fenetre, text ='Images suivantes', bg = 'White', command = imagesuivante3) Boutonsuivant3.grid(row =9, column = 1, sticky = E) #création bouton précédent Boutonprecedent1 = Button(fenetre, text ='Images précédentes', bg = 'White', command = imageprecedente) Boutonprecedent1.grid(row =3, column = 1, sticky = W) Boutonprecedent2 = Button(fenetre, text ='Images précédentes', bg = 'White', command = imageprecedente2) Boutonprecedent2.grid(row =6, column = 1, sticky = W) Boutonprecedent3 = Button(fenetre, text ='Images précédentes', bg = 'White', command = imageprecedente3) Boutonprecedent3.grid(row =9, column = 1, sticky = W) fenetre.mainloop()