Skip to content

Commit 34d3805

Browse files
committed
2 parents b0c20d6 + 8ef61a7 commit 34d3805

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<h1>Life Span Calculator</h1>
2+
3+
Calculate your age in various units with this simple web application built using Python and PyWebIO.
4+
5+
## Table of Contents
6+
7+
- [Introduction](#introduction)
8+
- [Functionality](#functionality)
9+
- [Features](#features)
10+
- [Installation](#installation)
11+
- [Usage](#usage)
12+
13+
## Introduction
14+
15+
The Life Span Calculator is a web application that allows users to input their date of birth and calculates their age in years, months, days, and other time units. It is built using Python and the PyWebIO framework, providing an interactive and user-friendly experience.
16+
17+
## Features
18+
19+
- Calculate age based on date of birth and current date.
20+
- Display age in years, months, days, total days, total hours, total minutes, and total seconds.
21+
- Responsive UI with progress bar and formatted output using PyWebIO.
22+
23+
## Installation
24+
25+
1. Clone the repository:
26+
27+
`git clone https://github.com/JawadSher/Python-Projects-Beginner-to-Advance/tree/main/Project%2010%20-%20Life%20Span%20Calculator
28+
cd life-span-calculator`
29+
30+
2. Install the required dependencies:
31+
32+
33+
`pip install pywebio`
34+
35+
36+
## Usage
37+
38+
1. Run the application:
39+
40+
41+
`python main.py`
42+
43+
2. Open your web browser and navigate to http://localhost:8080/ to access the Life Span Calculator.
44+
45+
3. Enter your date of birth in the provided input field and click "Calculate" to see your age displayed in various units.
46+
47+
This Python project, titled "Life Span Calculator," is a web application built using the PyWebIO framework. It allows users to calculate their age based on their date of birth and view the result in various time units (years, months, days, etc.). Here's an explanation of the components and functionalities of the project for GitHub viewers:
48+
49+
### Functionality:
50+
51+
1. **User Input (`user_birth()` Function):**
52+
53+
- The `user_birth()` function prompts the user to enter their date of birth using PyWebIO's `input` function with `type=DATE`. It ensures that the entered date of birth is not in the future relative to the current year by validating against `datetime.datetime.now().year`.
54+
2. **Date Calculation (`calculate_age()` Function):**
55+
56+
- The `calculate_age()` function computes the age in years, months, days, total days, total hours, total minutes, and total seconds based on the user's date of birth and the current date. It handles edge cases where the number of months or days might need adjustment due to differences in calendar dates.
57+
3. **Output (`info_table()` Function):**
58+
59+
- The `info_table()` function displays the calculated results using PyWebIO's output functions (`put_progressbar` for a loading bar and `put_table` for a formatted table). It presents the date of birth, current date, total age, total days, total months, total hours, total minutes, and total seconds in a structured format within a table. Additionally, it includes an image fetched from an external URL to enhance the visual presentation.
60+
4. **Main Function (`main()` Function):**
61+
62+
- The `main()` function serves as the entry point of the application. It initializes the PyWebIO server, displays a welcome message (`put_html`), retrieves the user's date of birth, calculates the age, and then displays the results using the `info_table()` function.
63+
5. **Server Start (`start_server()` Function):**
64+
65+
- The `start_server()` function starts the PyWebIO server, running the `main()` function. It opens the application in the default web browser (`auto_open_webbrowser=True`) on port 8080.
66+
67+
### Project Usage:
68+
69+
- This project can be used as a learning example for building web applications using PyWebIO, demonstrating how to handle user input, perform calculations, and display results in a user-friendly format.
70+
- GitHub viewers can clone the repository, explore the code, and run the application locally to understand its functionality and modify it according to their needs.
71+
72+
### Project Benefits:
73+
74+
- **Educational:** Demonstrates integration of PyWebIO for web-based user interfaces in Python.
75+
- **Practical:** Provides a practical example of date manipulation and age calculation.
76+
- **Interactive:** Utilizes PyWebIO's interactive input and output features for a seamless user experience.
77+
78+
This README template provides a structured and informative overview of your Life Span Calculator project, helping GitHub viewers understand its purpose, features, installation steps, and how to use the application effectively. Adjust it further to fit any additional details or specifics unique to your implementation.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This repository includes various Python projects:
1515
| 7. [Get Live Weather Desktop Notifications](https://github.com/JawadSher/Python-Projects-Beginner-to-Advance/tree/main/Project%207%20-%20Get%20Live%20Weather%20Desktop%20Notifications) | Application for fetching Latest Weather Updates & Display through Desktop Notifications |
1616
| 8. [Python Keyloger](https://github.com/JawadSher/Python-Projects-Beginner-to-Advance/tree/main/Project%208%20-%20Python%20Keyloger) | Capturing the client keyboard keys |
1717
| 9. [Attendence Management System](https://github.com/JawadSher/Python-Projects-Beginner-to-Advance/tree/main/Project%209%20-%20Class%20Attendence%20Management) | Basic Attendence Management System for School Classes |
18+
| 10. [Life Span Calculator](https://github.com/JawadSher/Python-Projects-Beginner-to-Advance/tree/main/Project%2010%20-%20Life%20Span%20Calculator) | A basic project by using the PyWebIO framework to build web app to calculate person total age span.
1819

1920
## Introduction
2021

0 commit comments

Comments
 (0)