PyQt5 – Beats and Breaths Calculator
In this article we will see how we can create a heart beats and breaths calculator using PyQt5. Below is how the calculator will look like.
A normal resting heart rate for adults ranges from 60 to 100 beats per minute. Generally, a lower heart rate at rest implies more efficient heart function and better cardiovascular fitness. For example, a well-trained athlete might have a normal resting heart rate closer to 40 beats per minute.
Respiratory rate: A person’s respiratory rate is the number of breaths you take per minute. The normal respiration rate for an adult at rest is 12 to 20 breaths per minute. A respiration rate under 12 or over 25 breaths per minute while resting is considered abnormal.
GUI Implementation Steps :
1. Create a heading label that display the calculator name
2. Create label to show user to select the birth date and the birth time
3. Create a QCalendarWidget object for user to select the birth date
4. Create a QTimeEdit object to get the birth time
5. Create a push button to calculate the heart beats and breaths
6. Create a label to show the calculated beats and breaths
Back-End Implementation :
1. Make the calendar future date block i.e set current date as maximum date
2. Add action to the push button
3. Inside the push button action get the date from the calendar and time from the QTimeEdit
4. Get the day, month and year from the date and hour and minute from the time edit
5. Create a datetime object for current date and the birth date
6. Get the difference from both the dates and get the days and seconds
7. Convert days and seconds into minutes
8. Get the heart beats and breaths by multiplying minutes with the average rates.
9. Show the calculated beats and breaths with the help of label
Below is the implementation