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
| def animate_temp(i):
global hour_tab, temperature_tab, humidite_tab
axtemp.clear()
ax2temp.clear()
axtemp.plot(hour_tab, temperature_tab, 'r')
axtemp.set_xlim(right = 60 , left = 0)
axtemp.set_xlabel("Temps [minutes]")
axtemp.set_ylabel("Température extérieure [°C]")
axtemp.set_title("Température et humidité extérieure durant la dernière heure")
ax2temp.set_ylabel('Humidité extérieure [%RH]')
ax2temp.plot(hour_tab, humidite_tab, 'c')
ax2temp.set_ylim(top = 100 , bottom = 0)
def animate_pluie(i):
global hour_tab, pluie_tab, pression_tab
print("test")
axpluie.clear()
ax2pluie.clear()
axpluie.plot(hour_tab, pluie_tab, 'r')
axpluie.set_ylim(bottom = 0)
axpluie.set_xlim(right = 60 , left = 0)
axpluie.set_xlabel("Temps [minutes]")
axpluie.set_ylabel("Hauteur de pluie [mm]")
axpluie.set_title("Pluie tombée et pression extérieure durant la dernière heure")
ax2pluie.set_ylabel('Pression atmosphérique [hpa]')
ax2pluie.plot(hour_tab, pression_tab, 'c')
ax2pluie.set_ylim(top = 1050 , bottom = 950)
def animate(i):
global eau_tab, hour_tab, debit_tab
ax.clear()
ax2.clear()
ax.plot(hour_tab, eau_tab, 'c')
ax.set_xlim(right = 60 , left = 0)
ax.set_xlabel("Temps [minutes]")
ax.set_ylabel("Volume d'eau consommé [litres]")
ax.set_title("Eau consommée totale et débit durant la dernière heure")
ax2.set_ylabel('Débit [l/min]')
ax2.plot(hour_tab, debit_tab, 'r')
def tab_changed(event): #Détecte le changement d'onglet
global ani, ani2, ani3
print(onglet.index(onglet.select()))
if onglet.index(onglet.select()) == 0 :
print("test0")
if 'ani' in globals(): del ani
if 'ani2' in globals(): del ani2
if 'ani3' in globals(): del ani3
elif onglet.index(onglet.select()) == 1 :
print("test1")
ani = animation.FuncAnimation(figure, animate, interval=10000)
elif onglet.index(onglet.select()) == 2 :
print("test2")
ani3 = animation.FuncAnimation(figurepluie, animate_pluie, interval=10000)
elif onglet.index(onglet.select()) == 3 :
print("test3")
ani2 = animation.FuncAnimation(figuretemp, animate_temp, interval=10000)
onglet.bind("<<NotebookTabChanged>>",tab_changed) |
Partager