Bonjour,
Je cherche à exécuter ce programme Python pour faire en sorte que le rond vert (Rvert) apparaisse une fois que le rond rouge a disparu.
Quelqu'un aurait-il la solution ?


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
68
69
70
71
72
73
74
75
76
77
78
import tkinter as tk
from tkinter import *
from tkinter import PhotoImage
 
tst = tk.Tk()
tst.title("La salle connection")
tst.config(bg="white")
tst.geometry("500x567")
 
# Chargement des deux images
Rrouge = PhotoImage(file='rrouge.png')
Rvert = PhotoImage(file='rvert.png')
 
# Création zone 1 
zone1 = Canvas(tst, width=50, height=50, bg="white")
zone1.create_image(27, 27, image=Rrouge)
zone1.place(x=300, y=2)
zone1bi = Canvas(tst, width=50, height=50, bg="white")
zone1bi.create_image(27, 27, image=Rvert)
zone1bi.place(x=300, y=2)
 
# Création zone 2
zone2 = Canvas(tst, width=50, height=50, bg="white")
zone2.create_image(27, 27, image=Rrouge)
zone2.place(x=350, y=60)
zone2bi = Canvas(tst, width=50, height=50, bg="white")
zone2bi.create_image(27, 27, image=Rvert)
zone2bi.place(x=350, y=60)
 
# Création zone 3
zone3 = Canvas(tst, width=50, height=50, bg="white")
zone3.create_image(27, 27, image=Rrouge)
zone3.place(x=400, y=120)
zone3bi = Canvas(tst, width=50, height=50, bg="white")
zone3bi.create_image(27, 27, image=Rvert)
zone3bi.place(x=400, y=120)
 
# Création zone 4
zone4 = Canvas(tst, width=50, height=50, bg="white")
zone4.create_image(27, 27, image=Rrouge)
zone4.place(x=350, y=180)
zone4bi = Canvas(tst, width=50, height=50, bg="white")
zone4bi.create_image(27, 27, image=Rvert)
zone4bi.place(x=350, y=180)
 
# Création zone 5
zone5 = Canvas(tst, width=50, height=50, bg="white")
zone5.create_image(27, 27, image=Rrouge)
zone5.place(x=300, y=240)
zone5bi = Canvas(tst, width=50, height=50, bg="white")
zone5bi.create_image(27, 27, image=Rvert)
zone5bi.place(x=300, y=240)
 
 
# Fonction pour faire clignoter les images
def clignotement():
    def switch_images():
        zone1.place()  # Afficher le rond rouge
        zone1bi.place_forget()  # Cacher le rond vert
        tst.update()
        tst.after(1000)  # Planifier l'affichage du rond vert après 3 secondes
        zone1.place_forget()  # Cacher l'autre zone
        zone1bi.place()  # Afficher la zone donnée
        dernière_chance()
 
    def dernière_chance():
        zone1bi.place()
 
 
 
 
    switch_images()
 
clignotement()
 
 
 
tst.mainloop()