-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestGUI.py
More file actions
62 lines (45 loc) · 1.39 KB
/
testGUI.py
File metadata and controls
62 lines (45 loc) · 1.39 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
import time
import matplotlib.pyplot as plt
tableau = ['3036', '2896', '2772', '2', '3023', '2887', '2771', '2660', '3008', '2879', '2766', '2666', '1413',
'1376', '13', '2655']
Z = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
coordinates_x = [0, 1, 2, 3]
coordinates_y = [0, 1, 2, 3]
plt.ion()
# creating subplot and figure
fig, ax = plt.subplots()
# setting labels
plt.title("Updating plot...")
plt.axis('off')
max_y = 3
texts = {}
for y in range(4):
for x in range(4):
texts[f'{x}:{y}'] = ax.text(x, max_y - y, f'{tableau[y * 4 + x]}', color="black", ha="center", va="center")
print(tableau)
for i in range(len(tableau)):
print(f'{tableau[i]:^6}', end="|")
if (i + 1) % 4 == 0:
print("")
# looping
for i in range(150):
vals = [
# Convert each element of the subset (from i to i+4) using map to int, wrapped as a list
list(map(int, tableau[i:i + 4]))
# iterate from 0 to tableau length (16) step by 4
for i in range(0, len(tableau), 4)
][::-1]
print(vals)
ax.pcolormesh(coordinates_x, coordinates_y, vals,
vmin=0,
vmax=4500
)
for y in range(4):
for x in range(4):
texts[f'{x}:{y}'].set_text(f'{tableau[y * 4 + x]}')
# re-drawing the figure
fig.canvas.draw()
# to flush the GUI events
fig.canvas.flush_events()
fig.tight_layout()
time.sleep(0.5)