-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.py
More file actions
83 lines (73 loc) · 2.4 KB
/
Copy pathInterface.py
File metadata and controls
83 lines (73 loc) · 2.4 KB
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
79
80
81
82
83
from tkinter import *
def clignotement_rect():
global rect_status
global rect
# Si le rectangle est affiché
if rect_status == 'place':
# On le cache et on change son statut
canvas.delete(rect)
rect_status = 'not_place'
else:
# On l'affiche et on change son status
rect = canvas.create_rectangle(base_x, base_y, base_x+large, base_y+hauteur, fill='red')
canvas.pack()
rect_status = 'place'
# Et on boucle tout les 143ms soit 7Hz
fenetre.after(143, clignotement_rect)
def clignotement_tri():
global tri_status
global tri
# Si le triangle est affiché
if tri_status == 'place':
# On le cache et on change son statut
canvas.delete(tri)
tri_status = 'not_place'
else:
# On l'affiche et on change son status
tri = canvas.create_polygon(x0, y0, x1, y1, x2, y2,fill='green')
canvas.pack()
tri_status = 'place'
# Et on boucle tout les 71ms soit 14Hz
fenetre.after(71, clignotement_tri)
def clignotement_oval():
global oval_status
global oval
# Si le triangle est affiché
if oval_status == 'place':
# On le cache et on change son statut
canvas.delete(oval)
oval_status = 'not_place'
else:
# On l'affiche et on change son status
oval = canvas.create_oval(x2+espacement_x,base_y,x2+espacement_x+large,base_y+hauteur,fill='yellow')
canvas.pack()
oval_status = 'place'
# Et on boucle tout les 47ms soit 21Hz
fenetre.after(47, clignotement_oval)
rect_status='place'
tri_status='place'
oval_status='place'
fenetre = Tk()
xmax=1250
ymax=500
fenetre.geometry("1250x500")
canvas = Canvas(fenetre, width=1250, heigh=500, background='grey')
# Coordonée clé
large = 175
hauteur = 175
base_x = 150
base_y = 250-large/2
espacement_x = 200
# Création forme
rect = canvas.create_rectangle(base_x, base_y, base_x+large,base_y+hauteur, fill='red')
x0 = base_x+large+espacement_x; y0 = base_y+hauteur
x1 = x0+large/2; y1 = base_y
x2 = x0+large; y2 = y0
tri = canvas.create_polygon(x0, y0, x1, y1, x2, y2,fill='green')
oval = canvas.create_oval(x2+espacement_x,base_y,x2+espacement_x+large,base_y+hauteur,fill='yellow')
canvas.pack()
# Methode
clignotement_rect()
clignotement_tri()
clignotement_oval()
fenetre.mainloop()