Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from random import randrange, randint
- x=randint(0, 200)
- y=randint(0, 200)
- r=15
- def disque():
- x=randint(0, 200)
- y=randint(0, 200)
- r=randint(1, 20)
- c=['red','green','blue','yellow','orange']
- i=randrange(5)
- can.create_oval(x-r, y-r, x+r, y+r, fill=c[i], outline=c[i])
- def haut():
- global x, y
- y -= 10
- can.coords(oval, x-r, y-r, x+r, y+r)
- def bas():
- global x, y
- y += 10
- can.coords(oval, x-r, y-r, x+r, y+r)
- def droite():
- global x, y
- x += 10
- can.coords(oval, x-r, y-r, x+r, y+r)
- def gauche():
- global x, y
- x -= 10
- can.coords(oval, x-r, y-r, x+r, y+r)
- fen = Tk()
- can = Canvas(fen, bg='white', height=200, width=200)
- can.pack(side=RIGHT)
- bout1 = Button(fen,text='Quitter',command=fen.destroy)
- bout1.pack(side=BOTTOM) #Comme Christine Boutin
- c=['red','green','blue','yellow','orange']
- i=randrange(5)
- oval = can.create_oval(x-r, y-r, x+r, y+r, fill=c[i], outline=c[i])
- boutHaut = Button(fen,text='Haut',command=haut)
- boutHaut.pack(side=TOP)
- boutBas = Button(fen,text='Bas',command=bas)
- boutBas.pack(side=TOP)
- boutDroite = Button(fen,text='Droite',command=droite)
- boutDroite.pack(side=TOP)
- boutGauche = Button(fen,text='Gauche',command=gauche)
- boutGauche.pack(side=TOP)
- fen.after(50,deplace)
- fen.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment