1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| from tkinter import *
from random import randint
def bulle(x,y,r,v,coul):
can.create_oval(x-r,y-r,x+r,y+r,fill=couleurs[coul])
#une liste paramUneBulle pour ranger chaques parametres(aleatoires) d'une bulle et rangés dans une liste paramToutesBulles
def afficheBulles():
paramToutesBulles=[[randint(10,190),190,randint(4,10),randint(1,10),randint(0,6)],[randint(10,190),190,randint(4,10),randint(1,10),randint(0,6)],[randint(10,190),190,randint(4,10),randint(1,10),randint(0,6)],[randint(10,190),190,randint(4,10),randint(1,10),randint(0,6)]]
Bulle=[0,0,0,0]
i=0
while i<len(paramToutesBulles):
paramUneBulle=paramToutesBulles[i]
Bulle[i]=bulle(paramUneBulle[0],paramUneBulle[1],paramUneBulle[2],paramUneBulle[3],paramUneBulle[4])
i=i+1
# création de la fenêtre et du canevas de dessin
fen = Tk()
fen.title('Champagne !')
can = Canvas(fen, width = 300, height = 200, background='black')
can.pack()
couleurs = ['white', 'red', 'green', 'blue', 'cyan', 'yellow', 'magenta'] # liste des couleurs possibles
afficheBulles()
fen.mainloop() |
Partager