Advertisement
Guest User

osekour

a guest
Oct 18th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #-*-codding:utf-8*-
  2. from Tkinter import*
  3.  
  4. x=250
  5. y=250
  6.  
  7.  
  8. def droite():
  9. global x,y
  10. x=x+10
  11. plateau.coords(disque,x,y)
  12. if x==499:
  13. x=0
  14.  
  15. def gauche():
  16. global x,y
  17. x=x-10
  18. plateau.coords(disque,x,y)
  19. if x==-499:
  20. x=0
  21.  
  22. def haut():
  23. global x,y
  24. y=y+10
  25. plateau.coords(disque,x,y)
  26. if y==499:
  27. y=0
  28.  
  29. def bas():
  30. global x,y
  31. y=y-10
  32. plateau.coords(disque,x,y)
  33. if y==-499:
  34. y=0
  35.  
  36.  
  37. fen = Tk()
  38. plateau=Canvas(fen, width=500, height=500)
  39. plateau.pack()
  40. disque=plateau.create_oval(245,245,255,255)
  41. frame=Frame(fen,width=200,height=100)
  42. frame.pack()
  43.  
  44. sortir=Button(frame,text="exit",command=fen.destroy)
  45. sortir.pack()
  46.  
  47. bouttonh=Button(frame,text="haut",command=haut)
  48. bouttonh.pack()
  49.  
  50. bouttonb=Button(frame,text="bas",command=bas)
  51. bouttonb.pack()
  52.  
  53. bouttong=Button(frame,text="gauche",command=gauche)
  54. bouttong.pack()
  55.  
  56. bouttond=Button(frame,text="droite",command=gauche)
  57. bouttond.pack()
  58.  
  59.  
  60. fen.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement