from tkinter import *
import matplotlib.pyplot as plt
import numpy as np

#Les fonctions--------------------------------------------
def afficher(val):
        T=float(val)
        A=0.5
        t=np.linspace(0,16,500)
        S = A*np.sin((2*np.pi/T)*t)
        legende="T={0:1.1f} s".format(T)
        plt.clf()
        plt.title("S=f(t)")
        plt.xlabel("Temps en s")
        plt.ylabel("Amplitude du signal S")
        plt.grid()
        plt.plot(t, S, color='red', label=legende)
        plt.legend(loc='upper right')

#Le programme principal-----------------------------------
Interface=Tk()
plt.ion()
T=Scale(Interface, orient='horizontal', from_=1, to=10,
          resolution=0.1, tickinterval=1, length=350,
          label='Période T(en s)', command=afficher)
T.pack()
Interface.mainloop()