Inverser l'ordre de défilement
Bonjour.
J'ai créé 101 images. J'arrive à les faire défiler de 0 à 100, une fois arrivé à 100, j'arrive à les refaire défiler, de 0 à 100.
Code:
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
| def anim1():
global i, img
i = i + 1
img = PhotoImage(file="D:/BOULOT/ISN/Nouveau/spectroscope"+str(i)+".gif")
Fond.itemconfig(Spectro, image = img)
Fond.coords(Spectro,0,0)
if i==100: i=0
fenetre.after(10,anim1)
fenetre=Tk()
fenetre.title("Spectrophotomètre")
Fond=Canvas(fenetre,width=640,height=480,bg="white")
Fond.grid()
img = PhotoImage(file="D:/BOULOT/ISN/Nouveau/spectroscope0.gif")
Spectro = Fond.create_image(0,0,image=img,anchor='nw')
i = 0
anim1()
fenetre.mainloop() |
Sauf que... j'aimerais qu'une fois arrivé à 100, elles re-défilent de 100 à 0, etc...
J'ai tenté :
Code:
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
| from tkinter import *
def anim1():
global i, img
i = i + 1
img = PhotoImage(file="D:/BOULOT/ISN/Nouveau/spectroscope"+str(i)+".gif")
Fond.itemconfig(Spectro, image = img)
Fond.coords(Spectro,0,0)
if i==100:
i=i-1
img = PhotoImage(file="D:/BOULOT/ISN/Nouveau/spectroscope"+str(i)+".gif")
Fond.itemconfig(Spectro, image = img)
Fond.coords(Spectro,0,0)
fenetre.after(10,anim1)
fenetre=Tk()
fenetre.title("Spectrophotomètre")
Fond=Canvas(fenetre,width=640,height=480,bg="white")
Fond.grid()
img = PhotoImage(file="D:/BOULOT/ISN/Nouveau/spectroscope0.gif")
Spectro = Fond.create_image(0,0,image=img,anchor='nw')
i = 0
anim1()
fenetre.mainloop() |
Sauf que là, le programme se termine.
Merci d'avance.