-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate_age_app.py
93 lines (66 loc) · 2.46 KB
/
calculate_age_app.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
Created by *Abdullah EL-Yamany*
Learn by 'Osama ELzero'
Video Link ==>> https://youtu.be/eLRqoSXmLmk
video title ==> Learn python By Examples - Ceare GUI Exe App To Calculate Age
Note => In The End Video How to Convert the python file to .Exe
==========================
Calculate with Age Desktop App
With Tkinter
==========================
"""
from tkinter import *
from tkinter import messagebox
#------------------ function of Calculate Age -----------------#
def calc_age():
#Get Age In Years
age_value = age.get()
#Get Time Units
months = float(age_value) * 12
weeks = months * 4
days = float(age_value) * 365.25
hour = days * 24
minute = hour * 60
second = minute * 60
line_one = f"Your Age In Monthes Is: {int(months)}"
line_two = f"Your Age In Weeks Is: {int(weeks)}"
line_three = f"Your Age In Days Is: {int(days)}"
line_four = f"Your Age In Hours Is: {int(hour)}"
line_five = f"Your Age In Minutes Is: {minute}"
line_six = f"Your Age In Seconds Is: {second}"
all_lines = [line_one, line_two, line_three, line_four, line_five, line_six]
messagebox.showinfo("Your Age In All Time Units", "\n".join(all_lines))
#------------------------- Gui Window ---------------------#
# Create the Main App Window
age_app = Tk()
# Change App Title/Name
age_app.title("Calculate Age App")
# Set Dimensions
age_app.geometry('400x350')
# Window Title Label
text = Label(age_app, text='Calculate Age App', font=('Arial', 20), height=2,fg='white', bg='black')
text.pack(fill=X) # Palce the text Into The window
# Write Age Label
text = Label(age_app, text='Write You Age :', font=('Arial', 16),bg='white')
text.pack(pady=30) # Palce the text Into The window
# Age Variables
age = StringVar() # string variable Change, User Can update it ##########################
# set Default Value For Age
age.set("00.0") ######################
# Create The Input For Age
age_input = Entry(age_app, width=4, font=("Arial, 20"), textvariable=age) ####################
age_input.pack() # Palce the Input Into The window
# Create The Calculate Button
btn = Button(
age_app,
text='Calculate Age',
width=10,
font=("Arial", 13),
fg='white',
bg='blue',
borderwidth=0,
command=calc_age
)
btn.pack(pady=15)
# Run App Infinitely
age_app.mainloop()