Pouknouki

Untitled

Feb 11th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. from tkinter import *
  2. from random import randrange, randint
  3.  
  4. x=randint(0, 200)
  5. y=randint(0, 200)
  6. r=15
  7.  
  8. def disque():
  9.     x=randint(0, 200)
  10.     y=randint(0, 200)
  11.     r=randint(1, 20)
  12.     c=['red','green','blue','yellow','orange']
  13.     i=randrange(5)
  14.     can.create_oval(x-r, y-r, x+r, y+r, fill=c[i], outline=c[i])
  15.    
  16. def haut():
  17.     global x, y
  18.     y -= 10
  19.     can.coords(oval, x-r, y-r, x+r, y+r)
  20.  
  21. def bas():
  22.     global x, y
  23.     y += 10
  24.     can.coords(oval, x-r, y-r, x+r, y+r)
  25.  
  26. def droite():
  27.     global x, y
  28.     x += 10
  29.     can.coords(oval, x-r, y-r, x+r, y+r)
  30.    
  31. def gauche():
  32.     global x, y
  33.     x -= 10
  34.     can.coords(oval, x-r, y-r, x+r, y+r)
  35.    
  36.  
  37. fen = Tk()
  38. can = Canvas(fen, bg='white', height=200, width=200)
  39. can.pack(side=RIGHT)
  40. bout1 = Button(fen,text='Quitter',command=fen.destroy)
  41. bout1.pack(side=BOTTOM) #Comme Christine Boutin
  42.  
  43.  
  44.  
  45. c=['red','green','blue','yellow','orange']
  46. i=randrange(5)
  47. oval = can.create_oval(x-r, y-r, x+r, y+r, fill=c[i], outline=c[i])
  48.  
  49.  
  50. boutHaut = Button(fen,text='Haut',command=haut)
  51. boutHaut.pack(side=TOP)
  52. boutBas = Button(fen,text='Bas',command=bas)
  53. boutBas.pack(side=TOP)
  54. boutDroite = Button(fen,text='Droite',command=droite)
  55. boutDroite.pack(side=TOP)
  56. boutGauche = Button(fen,text='Gauche',command=gauche)
  57. boutGauche.pack(side=TOP)
  58.  
  59. fen.after(50,deplace)
  60.  
  61. fen.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment