diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 00000000..d0f0167c --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/BMI calculator/Main.py b/BMI calculator/Main.py new file mode 100644 index 00000000..8646d28f --- /dev/null +++ b/BMI calculator/Main.py @@ -0,0 +1,126 @@ +from tkinter import * +import tkinter as tk +from tkinter import ttk +from PIL import Image, ImageTk + +root = Tk() +root.title("BMI Calculator") +root.geometry("470x580+300+200") +root.resizable(False, False) +root.configure(bg="#1e1e1e") # Sfondo scuro + +def BMI(): + h = float(Height.get()) + w = float(Weight.get()) + + m = h / 100 + bmi = round(float(w / m**2), 1) + label1.config(text=bmi) + + if bmi <= 18.5: + label2.config(text="Underweight!") + label3.config(text="Lower weight than normal body!") + elif 18.5 < bmi <= 25: + label2.config(text="Normal!") + label3.config(text="You are healthy!") + elif 25 < bmi < 30: + label2.config(text="Overweight!") + label3.config(text="You are slightly overweight!") + else: + label2.config(text="Obese!") + label3.config(text="Health may be at risk!") + +# Icon +image_icon = PhotoImage(file="Sprites/bmiIcon.png") +root.iconphoto(False, image_icon) + + +# Mostra l'immagine in un'etichetta + +top = PhotoImage(file="Sprites/Sif247.png") +top_image = Label(root, image = top, background="#f0f1f5") +top_image.place(x = -10, y=-10) + +# Bottom box +Label(root, width=72, height=18, bg="#2a2a2a").pack(side=BOTTOM) + +# Two boxes +box = PhotoImage(file="Sprites/box.png") +Label(root, image=box).place(x=20, y=100) +Label(root, image=box).place(x=240, y=100) + +# Scale +scale = PhotoImage(file="Sprites/scale.png") +Label(root, image=scale, bg="#2a2a2a").place(x=20, y=310) + +# Slider1 +current_value = tk.DoubleVar() + +def get_current_value(): + return '{:.2f}'.format(current_value.get()) + +def slider_changed(event): + Height.set(get_current_value()) + size = int(float(get_current_value())) + img = Image.open("Sprites/Man.png") + resized_image = img.resize((150, 30 + size)) + photo2 = ImageTk.PhotoImage(resized_image) + secondimage.config(image=photo2) + secondimage.place(x=70, y=525 - size) + secondimage.image = photo2 + +style = ttk.Style() +style.configure("TScale", background="white") + +slider = ttk.Scale(root, from_=0, to=220, orient='horizontal', style="TScale", + command=slider_changed, variable=current_value) +slider.place(x=80, y=250) + +# Slider2 +current_value2 = tk.DoubleVar() + +def get_current_value2(): + return '{:.2f}'.format(current_value2.get()) + +def slider_changed2(event): + Weight.set(get_current_value2()) + +style2 = ttk.Style() +style2.configure("TScale", background="white") + +slider2 = ttk.Scale(root, from_=0, to=200, orient='horizontal', style="TScale", + command=slider_changed2, variable=current_value2) +slider2.place(x=300, y=250) + +# Entry box +Height = StringVar() +Weight = StringVar() + +Label(root, text="Height: cm", font='arial 12', bg='#1e1e1e', fg='#fff').place(x=35, y=130) +Label(root, text="Weight: kg", font='arial 12', bg='#1e1e1e', fg='#fff').place(x=255, y=130) + + +height = Entry(root, textvariable=Height, width=5, font='arial 50', bg='#444', fg='#fff', bd=0, justify=CENTER) +height.place(x=35, y=160) +Height.set(get_current_value()) + +weight = Entry(root, textvariable=Weight, width=5, font='arial 50', bg='#444', fg='#fff', bd=0, justify=CENTER) +weight.place(x=255, y=160) +Weight.set(get_current_value2()) + +# Man image +secondimage = Label(root, bg="#2a2a2a") +secondimage.place(x=70, y=530) + +Button(root, text="View Report", width=15, height=2, font="arial 10 bold", bg="#3b5998", fg="white", command=BMI).place(x=280, y=340) + +label1 = Label(root, font="arial 60 bold", bg="#2a2a2a", fg="#fff") +label1.place(x=250, y=400) + +label2 = Label(root, font="arial 20 bold", bg="#2a2a2a", fg="#fff") +label2.place(x=250, y=480) + +label3 = Label(root, font="arial 10 bold", bg="#2a2a2a", fg="#fff") +label3.place(x=250, y=550) + +root.mainloop() diff --git a/BMI calculator/README.md b/BMI calculator/README.md new file mode 100644 index 00000000..8c6675d7 --- /dev/null +++ b/BMI calculator/README.md @@ -0,0 +1,55 @@ + + +# BMI Calculator + +BMI Calculator is a desktop application written in Python using the Tkinter library, which allows users to calculate their **Body Mass Index** (BMI) based on their height and weight. The user interface is designed to be intuitive and modern, with slider controls and dynamic visualization. + +## Features + +- BMI calculation based on height (in centimeters) and weight (in kilograms). +- Interactive adjustment of height and weight through sliders. +- BMI classification based on standard guidelines (underweight, normal, overweight, obese). +- Modern and user-friendly graphical interface with custom images and colors. +- Display of personalized health suggestions based on the BMI result. + +## How It Works + +1. Set your height using the slider on the left or manually enter the value in the "Height" field. +2. Set your weight using the slider on the right or manually enter the value in the "Weight" field. +3. Click the "View Report" button to calculate your BMI. +4. The result will be displayed at the bottom, along with a classification and health advice. + +## Requirements + +- **Python 3.x** +- **Tkinter** (usually pre-installed with Python) +- **Pillow** (for image handling) + +To install Pillow, you can run: + +```bash +pip install Pillow +``` + +## How to Run + +1. Clone or download the project to your local directory. +2. Make sure you have the required dependencies installed. +3. Run the main Python file: + +```bash +python bmi_calculator.py +``` + +## Project Structure + +- **bmi_calculator.py**: The main file containing the application's logic and graphical interface. +- **Sprites/**: The folder containing all images used in the application, such as icons and backgrounds. + +## Interface Example + +

+ Image 1 + Image 2 + Image 3 +

diff --git a/BMI calculator/Sprites/Man.png b/BMI calculator/Sprites/Man.png new file mode 100644 index 00000000..509cb6ec Binary files /dev/null and b/BMI calculator/Sprites/Man.png differ diff --git a/BMI calculator/Sprites/Sif247.png b/BMI calculator/Sprites/Sif247.png new file mode 100644 index 00000000..a72d09ab Binary files /dev/null and b/BMI calculator/Sprites/Sif247.png differ diff --git a/BMI calculator/Sprites/bmiIcon.png b/BMI calculator/Sprites/bmiIcon.png new file mode 100644 index 00000000..850eb9f3 Binary files /dev/null and b/BMI calculator/Sprites/bmiIcon.png differ diff --git a/BMI calculator/Sprites/box.png b/BMI calculator/Sprites/box.png new file mode 100644 index 00000000..65f29d9a Binary files /dev/null and b/BMI calculator/Sprites/box.png differ diff --git a/BMI calculator/Sprites/scale.png b/BMI calculator/Sprites/scale.png new file mode 100644 index 00000000..9c741ce1 Binary files /dev/null and b/BMI calculator/Sprites/scale.png differ diff --git a/BMI calculator/img/im1.png b/BMI calculator/img/im1.png new file mode 100644 index 00000000..3ba6f9a1 Binary files /dev/null and b/BMI calculator/img/im1.png differ diff --git a/BMI calculator/img/im2.png b/BMI calculator/img/im2.png new file mode 100644 index 00000000..18e45af4 Binary files /dev/null and b/BMI calculator/img/im2.png differ diff --git a/BMI calculator/img/im3.png b/BMI calculator/img/im3.png new file mode 100644 index 00000000..aa3bf13e Binary files /dev/null and b/BMI calculator/img/im3.png differ