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 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| from tkinter import *
#création du monde quadrillé
#création de la grille vide
def damier() :
ligne_vert()
ligne_hori()
def ligne_vert() :
x = 0
while x <= 750 :
C.create_line(x, 0, x, 600)
x += 15
def ligne_hori() :
y = 0
while y <= 600 :
C.create_line(0, y, 750, y)
y += 15
fen=Tk()
fen.title('Trajet du plastique dans les océans')
fen.geometry("750x800")
C=Canvas(fen, bg='white', width = 750, height = 600)
#fonction test pour scale
def test (n) :
C.create_rectangle(n, n, n+15, n+15, fill='black')
#remplissage de la grille pour les terres
#australie
C.create_rectangle(630,375,645,465, fill='black')
C.create_rectangle(645,420,660,450, fill='black')
Valeur=StringVar(fen)
S = Scale (fen,orient='horizontal', from_=0, to=365, resolution=1, tickinterval=50, length=350, label='Temps (jours)', relief='raised', width=10,variable=Valeur, command=test).pack(side = LEFT and BOTTOM)
damier()
C.place(x=0, y=0)
fen.mainloop() |
Partager