-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (47 loc) · 1.32 KB
/
main.py
File metadata and controls
58 lines (47 loc) · 1.32 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
from tkinter import *
#window
window = Tk()
window.title("BMI Hesaplama")
window.minsize(width=250, height=250)
window.config(bg="lightblue")
#label kg
label_kg = Label(text="Kilonuzu Giriniz (kg):", bg="lightblue" ,fg="black")
label_kg.config(pady=10)
label_kg.pack()
#entry_kg
entry_kg = Entry(width=20)
entry_kg.pack()
#label boy
label_boy = Label(text="Boyunuzu Giriniz (cm):", bg="lightblue" ,fg="black")
label_boy.config(padx=10, pady=20)
label_boy.pack()
#entry boy
entry_boy = Entry(width=20)
entry_boy.pack()
#hesapla fonksiyonu
def calculator():
weight = float(entry_kg.get())
height = float(entry_boy.get()) /100 # cm = m çeviri
bmi = weight / (height * height)
bmi_result = round(bmi, 2)
if bmi <= 18.5:
kategori = "zayıf"
renk ="blue"
elif bmi <= 25:
kategori = "normal"
renk = "green"
elif bmi <= 30:
kategori = "fazla kilolu"
renk = "yellow"
else:
kategori = "obez"
renk = "red"
result_label.config(
text=f"BMI:{bmi_result}\nKategori: {kategori}", fg=renk)
result_label= StringVar()
result_label = Label(text="", bg="lightblue", fg="black")
result_label.pack(pady=10)
#button hesapla
hesapla_button = Button(text="Hesapla", command=calculator, bg="white", fg="black")
hesapla_button.pack(pady=0)
window.mainloop()