diff --git a/projet_8.py b/projet_8.py new file mode 100644 index 0000000..42481f8 --- /dev/null +++ b/projet_8.py @@ -0,0 +1,37 @@ +#faire un Entry pour entrer la taille en cm et le poids en kg(float) +#un bouton qui calcule l'IMC + l'affiche dans un Label + +from tkinter import* + +fenetre = Tk() +fenetre.title("Calcul IMC") + + +#Taille# +label_taille = Label(text="Taille (en cm)") +label_taille.grid(row=1, column=1) +value = IntVar() +Taille = Entry(textvariable=value, bd=5) +Taille.grid(row=2, column=1) + +#Poids# +label_poids = Label(text="Poids (en kg)") +label_poids.grid(row=1, column=2) +value_2 = IntVar() +Poids = Entry(fenetre, textvariable=value_2, bd=5) +Poids.grid(row=2, column=2) + +#Calcul et affichage IMC# +def imc(): + imc_calcul = round((value_2.get() / value.get()**2) * 10000, 1) + print(imc_calcul) + label_imc = Label(text="Votre IMC est de: " + str(imc_calcul)) + label_imc.grid(row=4, column=1, columnspan=2) + +#Valider# +button = Button(text="Valider", command=imc) +button.grid(row=3, column=1, columnspan=2) + + + +fenetre.mainloop() \ No newline at end of file