Bonsoir,

je teste ce programme et j'ai du mal avec la fonction time.sleep()

quelqu'un aurait-il un éclairage

Merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python
# -*- coding: cp1252 -*-
 
 
# mon projet de feux de carrefour
# avec tkinter
from Tkinter import*
#! /usr/bin/env python
# -*- coding: Latin-1 -*-
 
# Petit exercice utilisant la librairie graphique Tkinter
 
import time
# programme principal
# les variables suivantes seront utilisées de manière globale :
x1, y1 =200,20        # coordonnées initiales
x2, y2 =280,570        # coordonnées initiales de la voiture
 
 
# Création du widget principal ("maître") :
root=Tk()# -*- coding: cp1252 -*-
 
root.title("Exercice d'animation avec Tkinter")
# création des widgets "esclaves" :
 
# dessiner le fond
 
a = 0
b = 0
 
can1 = Canvas(root, bg='dark grey',height=640,width=480)
feux=can1.create_rectangle(100,100,290,590,width=5,fill='black')
 
 
led1=can1.create_oval(125,125,250,250,width=5,fill='white')
led2=can1.create_oval(125,280,250,400,width=5,fill='white')
led3=can1.create_oval(125,405,250,530,width=5,fill='white')
 
time.sleep(3)
 
# while  a  < 1 : 
    # print a
led1=can1.create_oval(125,125,250,250,width=5,fill='red')
time.sleep(3)
led1=can1.create_oval(125,125,250,250,width=5,fill='white')
led2=can1.create_oval(125,280,250,400,width=5,fill='yellow')   
#time.sleep(3)      
#    led3=can1.create_oval(125,445,250,530,width=5,fill='green')        
#    time.sleep(30)        
#    led3=can1.create_oval(125,405,250,530,width=5,fill='white')        
# while b < 7 :             
#    led2=can1.create_oval(125,280,250,400,width=5,fill='orange')            
#    time.sleep(5)            
#    b = b+1            
#    led2=can1.create_oval(125,280,250,400,width=5,fill='white')
# return
can1.pack(side=LEFT)
 
 
 
Button(root,text='Quitter',command=root.quit).pack(side=BOTTOM)
 
# Button(fen, text='Start', command =start).pack(side =LEFT, padx =10)
 
 
# démarrage du réceptionnaire d'évènements (boucle principale) :
root.mainloop()