|
@ -1,4 +1,5 @@ |
|
|
from tkinter import * |
|
|
from tkinter import * |
|
|
|
|
|
import tkinter as tk |
|
|
import matplotlib.pyplot as plt |
|
|
import matplotlib.pyplot as plt |
|
|
from matplotlib.pyplot import figure |
|
|
from matplotlib.pyplot import figure |
|
|
import numpy as np |
|
|
import numpy as np |
|
@ -6,23 +7,35 @@ fen = Tk() |
|
|
home = Frame() |
|
|
home = Frame() |
|
|
fen.title("Calculateur d'IMC") |
|
|
fen.title("Calculateur d'IMC") |
|
|
|
|
|
|
|
|
canvas=Canvas(fen, width=600, height=400, bg="white") #canvas de droite |
|
|
#taille de la fenetre |
|
|
|
|
|
fen.geometry("950x750") |
|
|
|
|
|
|
|
|
|
|
|
#image en fond |
|
|
|
|
|
#bg = PhotoImage(file = "fondec.png") |
|
|
|
|
|
#label1 = Label(fen, image = bg) |
|
|
|
|
|
#label1.place(x = 0, y = 0) |
|
|
|
|
|
|
|
|
|
|
|
#couleur de fond du canvas |
|
|
|
|
|
#fen.configure(bg="red") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canvas=Canvas(fen, width=600, height=500, bg="blue") #canvas de droite |
|
|
canvas.grid(column=1,row=0) #son placement |
|
|
canvas.grid(column=1,row=0) #son placement |
|
|
|
|
|
|
|
|
canvas2=Canvas(fen, width=150, height=400, bg="white") #canvas de gauche |
|
|
canvas2=Canvas(fen, width=225, height=500, bg="white") #canvas de gauche |
|
|
canvas2.grid(column=0, row=0) #son placement |
|
|
canvas2.grid(column=0, row=0) #son placement |
|
|
|
|
|
|
|
|
lbl1=Label(fen, text="votre poids (en kg)", font='Arial') #label poids |
|
|
lbl1=Label(fen, text="votre poids (en kg)", font='Arial') #label poids |
|
|
lbl1.grid(column=0, row=1) |
|
|
lbl1.grid(column=0, columnspan=2, padx=10, pady=10, row=1) |
|
|
|
|
|
|
|
|
entree_kg = Entry(fen) #entry poids |
|
|
entree_kg = Entry(fen) #entry poids |
|
|
entree_kg.grid(column=0, row=2) |
|
|
entree_kg.grid(column=0, columnspan=2,ipadx=50, padx=10, pady=10, row=2) |
|
|
|
|
|
|
|
|
lbl2=Label(fen, text="votre taille (en cm)", font='Arial') #label taille |
|
|
lbl2=Label(fen, text="votre taille (en cm)", font='Arial') #label taille |
|
|
lbl2.grid(column=0, row=3) |
|
|
lbl2.grid(column=0, columnspan=2, padx=10, pady=10, row=3) |
|
|
|
|
|
|
|
|
entree_cm = Entry(fen) #entry taille |
|
|
entree_cm = Entry(fen) #entry taille |
|
|
entree_cm.grid(column=0, row=4) |
|
|
entree_cm.grid(column=0, columnspan=2,ipadx=50, padx=10, pady=10, row=4) |
|
|
|
|
|
|
|
|
#photos |
|
|
#photos |
|
|
|
|
|
|
|
@ -32,7 +45,7 @@ image_obes = PhotoImage(file = 'obesite.png') |
|
|
image_sousp = PhotoImage(file = 'sous poids.png') |
|
|
image_sousp = PhotoImage(file = 'sous poids.png') |
|
|
image_surpoids = PhotoImage(file = 'surpoids.png') |
|
|
image_surpoids = PhotoImage(file = 'surpoids.png') |
|
|
|
|
|
|
|
|
|
|
|
#fonction qui affiche image imc+petite phrase |
|
|
def afficher_imc(): |
|
|
def afficher_imc(): |
|
|
taille = float(entree_cm.get())/100 #convertir cm en m |
|
|
taille = float(entree_cm.get())/100 #convertir cm en m |
|
|
poids= float(entree_kg.get()) |
|
|
poids= float(entree_kg.get()) |
|
@ -40,29 +53,30 @@ def afficher_imc(): |
|
|
|
|
|
|
|
|
if imc <=18.4: |
|
|
if imc <=18.4: |
|
|
text= canvas.create_text(200,40,anchor='center',text="vous etes en sous-poids", font=('Helvetica','30')) |
|
|
text= canvas.create_text(200,40,anchor='center',text="vous etes en sous-poids", font=('Helvetica','30')) |
|
|
canvas2.create_image(10, 10,anchor=NW, image = image_sousp) |
|
|
canvas2.create_image(40, 10,anchor=NW, image = image_sousp) |
|
|
|
|
|
|
|
|
if imc >=18.5 and imc<=24.9: |
|
|
if imc >=18.5 and imc<=24.9: |
|
|
text= canvas.create_text(200,40,text="votre poids est normal", font=('Helvetica','30',)) |
|
|
text= canvas.create_text(200,40,text="votre poids est normal", font=('Helvetica','30',)) |
|
|
canvas2.create_image(0,0,anchor=NW,image=image_norm) |
|
|
canvas2.create_image(40,10,anchor=NW,image=image_norm) |
|
|
|
|
|
|
|
|
if imc >=25.0 and imc<=29.9: |
|
|
if imc >=25.0 and imc<=29.9: |
|
|
text= canvas.create_text(200,40,text="vous êtes en sur poids", font=('Helvetica','30',)) |
|
|
text= canvas.create_text(200,40,text="vous êtes en sur poids", font=('Helvetica','30',)) |
|
|
canvas2.create_image(0, 0,anchor=NW, image = image_surpoids) |
|
|
canvas2.create_image(20, 20,anchor=NW, image = image_surpoids) |
|
|
|
|
|
|
|
|
if imc >=30.0 and imc<=34.9: |
|
|
if imc >=30.0 and imc<=34.9: |
|
|
text= canvas.create_text(200,40,text="vous etes en obesité", font=('Helvetica','30',)) |
|
|
text= canvas.create_text(200,40,text="vous etes en obesité", font=('Helvetica','30',)) |
|
|
canvas2.create_image(0, 0,anchor=NW, image = image_obes) |
|
|
canvas2.create_image(10, 10,anchor=NW, image = image_obes) |
|
|
|
|
|
|
|
|
if imc >=35.0: |
|
|
if imc >=35.0: |
|
|
text= canvas.create_text(200,40,text="vous etes en obesité sévère", font=('Helvetica','30',)) |
|
|
text= canvas.create_text(200,40,text="vous etes en obesité sévère", font=('Helvetica','30',)) |
|
|
canvas2.create_image(0, 0,anchor=NW, image = image_obes_s) |
|
|
canvas2.create_image(10, 10,anchor=NW, image = image_obes_s) |
|
|
|
|
|
|
|
|
lbl=Label(fen, text="votre imc est de :", font='Arial') |
|
|
lbl=Label(fen, text="votre imc est de :", font='Arial') |
|
|
lbl.grid(padx=15, pady=15) |
|
|
lbl.grid(column=0, row=1) |
|
|
lbl=Label(fen, text=imc, font='Arial') #afficher le resultat calcul imc |
|
|
lbl=Label(fen, text=imc, font='Arial') #afficher le resultat calcul imc |
|
|
lbl.grid(padx=15, pady=15) |
|
|
lbl.grid(column=0, row=2) |
|
|
# graphique |
|
|
|
|
|
|
|
|
# graphique |
|
|
|
|
|
|
|
|
new_manager = plt.figure().canvas.manager |
|
|
new_manager = plt.figure().canvas.manager |
|
|
fig=new_manager.canvas.figure |
|
|
fig=new_manager.canvas.figure |
|
@ -73,7 +87,7 @@ def afficher_imc(): |
|
|
plt.fill_between(x, 0, 18.5 * (x/100)**2, label="sous poids",color="LightBlue") # sous poids si 0 <= y <= 18.5 * x² |
|
|
plt.fill_between(x, 0, 18.5 * (x/100)**2, label="sous poids",color="LightBlue") # sous poids si 0 <= y <= 18.5 * x² |
|
|
plt.fill_between(x, 18.5 * (x/100)**2, 25 * (x/100)**2, label="poids idéal",color="yellow") # idéal si 18.5 * x² <= y <= 25 * x² |
|
|
plt.fill_between(x, 18.5 * (x/100)**2, 25 * (x/100)**2, label="poids idéal",color="yellow") # idéal si 18.5 * x² <= y <= 25 * x² |
|
|
|
|
|
|
|
|
# plt.scatter(entree_cm.get(), poids, color='gray') |
|
|
#plt.scatter(entree_cm.get(), poids, color='gray') point a placer sur le graphique |
|
|
|
|
|
|
|
|
plt.xlabel('Taille (cm)') |
|
|
plt.xlabel('Taille (cm)') |
|
|
plt.ylabel('Poids (kg)') |
|
|
plt.ylabel('Poids (kg)') |
|
@ -83,7 +97,7 @@ def afficher_imc(): |
|
|
plt.show() |
|
|
plt.show() |
|
|
|
|
|
|
|
|
bouton=Button(fen, text="Afficher l'IMC", command=afficher_imc) |
|
|
bouton=Button(fen, text="Afficher l'IMC", command=afficher_imc) |
|
|
bouton.grid(padx=50, pady=10) |
|
|
bouton.grid(column=0, columnspan=2,ipadx=50, padx=10, pady=10, row=6) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|