Advertisement
Alex_isaac

TP007-Lemarcheur

Feb 7th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import tkinter as Tk
  2. from PIL import Image,ImageTk
  3.  
  4. def anim():
  5.     global img,photo1,image,x
  6.     if img==8:
  7.         img=0
  8.     else:
  9.         img+=1
  10.     if x>=fen1.winfo_screenwidth():
  11.         x=0
  12.     else:
  13.         x=x+5
  14.     can1.delete(image)
  15.     image=Image.open('marche'+str(img)+'.gif')
  16.     photo1=ImageTk.PhotoImage(image)
  17.     can1.create_image(x,0,anchor=Tk.N,image=photo1)
  18.     fen1.after(50,anim)
  19.    
  20.    
  21. fen1=Tk.Tk()
  22. wFen=fen1.winfo_screenwidth()
  23. hFen=fen1.winfo_screenheight()
  24. dimFen=str(wFen)+'x'+str(int(hFen/2))+'+0+0'
  25. fen1.geometry(dimFen)
  26. fen1.configure(bg='green')
  27. pause=False
  28. img=0
  29. x=0
  30. image=Image.open('marche0.gif')
  31. photo1=ImageTk.PhotoImage(image)
  32. can1=Tk.Canvas(fen1,width=wFen,height=image.size[1],bg='white')
  33. can1.create_image(x,0,anchor=Tk.N,image=photo1)
  34. can1.pack(padx=10,pady=10)
  35.  
  36. Bou1=Tk.Button(fen1,text='Quit',command=fen1.destroy)
  37. Bou1.pack(side=Tk.BOTTOM)
  38. Bou2=Tk.Button(fen1,text='Pause',command=fen1.destroy)
  39. Bou2.pack(side=Tk.BOTTOM)
  40. if pause == False:
  41.     anim()
  42. elif pause == True:
  43.     anim()
  44.  
  45. fen1.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement