Advertisement
Alex_isaac

TP007 - Le marcheur - Laure

Feb 14th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. import tkinter as Tk
  2. from PIL import Image,ImageTk
  3.  
  4. def animation():
  5.     global i,x
  6.     if go==True:
  7.  
  8.         img=Image.open("marche"+str(i)+".gif")
  9.         photo=ImageTk.PhotoImage(img)
  10.            
  11.         can1.create_image(x,0,anchor=Tk.NW,image=photo)
  12.         can1.photo=photo
  13.         can1.pack
  14.  
  15.         fen1.after(80,animation)
  16.        
  17.     x=x+40
  18.     i=i+1
  19.          
  20.            
  21.     if i>8: i=1
  22.     if x>1366: x=0    
  23.        
  24.        
  25.    
  26.     return()
  27.    
  28. def pause():
  29.     global go
  30.     go=not go
  31.     if go==True:
  32.       animation()
  33.    
  34.  
  35.  
  36. #Programme principal
  37.  
  38. fen1=Tk.Tk()
  39. largeur=fen1.winfo_screenwidth()
  40. longueur=fen1.winfo_screenheight()
  41. taille=str(largeur)+"x"+str(longueur)+"+0+0"
  42. fen1.geometry(taille)
  43. fen1.configure(bg="green")
  44.  
  45. can1=Tk.Canvas(fen1,width=int(largeur-35),height=300,bg="white")
  46. can1.grid(padx=10,pady=10)
  47.  
  48. go=True
  49. x=0  
  50. i=1
  51. animer=animation()
  52.  
  53.  
  54. stop=Tk.Button(fen1,text="Pause",bg="white",fg="black", command=pause)
  55. stop.place(x=(largeur//2)-10,y=400)
  56. destroy=Tk.Button(fen1,text="Quitter",bg="white",fg="red", command=fen1.destroy)
  57.  
  58.  
  59. destroy.place(x=(largeur//2)-10,y=450)
  60. fen1.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement