Skip to content

Commit 09fc7ae

Browse files
Merge pull request prathimacode-hub#696 from akash435/absdeltabranch
Added Absolute Time Delta in GUIScripts
2 parents 437d3e2 + 60c14dc commit 09fc7ae

File tree

11 files changed

+255
-0
lines changed

11 files changed

+255
-0
lines changed
119 KB
Loading
126 KB
Loading
137 KB
Loading
135 KB
Loading
141 KB
Loading
138 KB
Loading
144 KB
Loading
139 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ✔ ABSOLUTE TIME DELTA
2+
- #### A "Absolute Time Delta" is an application created in python with tkinter gui.
3+
- #### In this application, user will be able to find the absolute time delta between two inputed time in a very precise way.
4+
- #### User can enter two times in terms of Day, Date, Month, Year, Hour, Minute, Second and Time Zone, and can get the absolute time difference between both this time in seconds.
5+
- #### Also when user has entered any thing wrong in the entry, then it will show error for the same.
6+
7+
****
8+
9+
# REQUIREMENTS :
10+
- #### python 3
11+
- #### tkinter module
12+
- #### from tkinter messagebox module
13+
- #### from datetime import datetime
14+
15+
****
16+
17+
# How this Script works :
18+
- #### User just need to download the file and run the absolute_time_delta.py on their local system.
19+
- #### Now on the main window of the application the user needs to enter the valid two times.
20+
- #### Also there is a sample button, clicking on which user will be able to see the sample input.
21+
- #### After entering both times, when user click son the ABS. DELTA button, he/she will be able to see the absolute difference in second of both the times.
22+
- #### And if there is error in entering times, then it will show error message like "You have entered wrong input."
23+
- #### Also there is a reset button, clicking on which reset all the entry box to empty.
24+
- #### Also there is an exit button, clicking on which exit dialog box appears asking for the permission of the user for closing the window.
25+
26+
# Purpose :
27+
- #### This scripts helps us to easily get the absolute difference between any two times very precisely.
28+
29+
# Compilation Steps :
30+
- #### Install tkinter, datetime
31+
- #### After that download the code file, and run absolute_time_delta.py on local system.
32+
- #### Then the script will start running and user can explore it by entering valid times and finding absolute delta for same.
33+
34+
****
35+
36+
# SCREENSHOTS :
37+
38+
****
39+
40+
<p align="center">
41+
<img width = 1000 src="Images/1.jpg" /><br>
42+
<img width = 1000 src="Images/2.jpg" /><br>
43+
<img width = 1000 src="Images/3.jpg" /><br>
44+
<img width = 1000 src="Images/4.jpg" /><br>
45+
<img width = 1000 src="Images/5.jpg" /><br>
46+
<img width = 1000 src="Images/6.jpg" /><br>
47+
<img width = 1000 src="Images/7.jpg" /><br>
48+
<img width = 1000 src="Images/8.jpg" /><br>
49+
</p>
50+
51+
****
52+
53+
# Name :
54+
- ### Akash Ramanand Rajak
55+
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
2+
# Absolute Time Delta
3+
4+
# imported necessary library
5+
import tkinter as tk
6+
import tkinter.messagebox as mbox
7+
from datetime import datetime
8+
from tkinter import *
9+
10+
# created main window
11+
window = Tk()
12+
window.geometry("1000x750")
13+
window.title("Absolute Time Delta")
14+
15+
16+
# top label
17+
start1 = tk.Label(text = "ABSOLUTE TIME DELTA", font=("Arial", 45), fg="magenta") # same way bg
18+
start1.place(x = 120, y = 10)
19+
20+
# time1 label
21+
time1 = tk.Label(text = "Time 1", font=("Arial", 30), fg="green") # same way bg
22+
time1.place(x = 400, y = 80)
23+
24+
# time2 label
25+
time1 = tk.Label(text = "Time 2", font=("Arial", 30), fg="green") # same way bg
26+
time1.place(x = 700, y = 80)
27+
28+
# Day label
29+
day_lbl = tk.Label(text = "Day :", font=("Arial", 30), fg="brown") # same way bg
30+
day_lbl.place(x = 50, y = 140)
31+
# Day Entry Box
32+
day_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
33+
day_time1_entry.place(x=350, y=140)
34+
day_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
35+
day_time2_entry.place(x=650, y=140)
36+
37+
# Date label
38+
date_lbl = tk.Label(text = "Date :", font=("Arial", 30), fg="brown") # same way bg
39+
date_lbl.place(x = 50, y = 200)
40+
# Date Entry Box
41+
date_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
42+
date_time1_entry.place(x=350, y=200)
43+
date_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
44+
date_time2_entry.place(x=650, y=200)
45+
46+
# Month label
47+
month_lbl = tk.Label(text = "Month :", font=("Arial", 30), fg="brown") # same way bg
48+
month_lbl.place(x = 50, y = 260)
49+
# Month Entry Box
50+
month_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
51+
month_time1_entry.place(x=350, y=260)
52+
month_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
53+
month_time2_entry.place(x=650, y=260)
54+
55+
# Year label
56+
year_lbl = tk.Label(text = "Year :", font=("Arial", 30), fg="brown") # same way bg
57+
year_lbl.place(x = 50, y = 320)
58+
# Year Entry Box
59+
year_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
60+
year_time1_entry.place(x=350, y=320)
61+
year_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
62+
year_time2_entry.place(x=650, y=320)
63+
64+
# Hour label
65+
hour_lbl = tk.Label(text = "Hour :", font=("Arial", 30), fg="brown") # same way bg
66+
hour_lbl.place(x = 50, y = 380)
67+
# Hour Entry Box
68+
hour_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
69+
hour_time1_entry.place(x=350, y=380)
70+
hour_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
71+
hour_time2_entry.place(x=650, y=380)
72+
73+
# Minute label
74+
minute_lbl = tk.Label(text = "Minute :", font=("Arial", 30), fg="brown") # same way bg
75+
minute_lbl.place(x = 50, y = 440)
76+
# Minute Entry Box
77+
minute_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
78+
minute_time1_entry.place(x=350, y=440)
79+
minute_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
80+
minute_time2_entry.place(x=650, y=440)
81+
82+
# Second label
83+
second_lbl = tk.Label(text = "Second :", font=("Arial", 30), fg="brown") # same way bg
84+
second_lbl.place(x = 50, y = 500)
85+
# Second Entry Box
86+
second_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
87+
second_time1_entry.place(x=350, y=500)
88+
second_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
89+
second_time2_entry.place(x=650, y=500)
90+
91+
# Zone label
92+
zone_lbl = tk.Label(text = "Time Zone :", font=("Arial", 30), fg="brown") # same way bg
93+
zone_lbl.place(x = 50, y = 560)
94+
# Day Entry Box
95+
zone_time1_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
96+
zone_time1_entry.place(x=350, y=560)
97+
zone_time2_entry = Entry(window, font=("Arial", 25), fg='orange', bg="light yellow", borderwidth=3, width=13)
98+
zone_time2_entry.place(x=650, y=560)
99+
100+
# function defined for finding the delta
101+
def get_delta():
102+
global valid
103+
time1 = str(day_time1_entry.get()) + " " + str(date_time1_entry.get()) + " " + str(month_time1_entry.get()) + " " + str(year_time1_entry.get()) + " " + str(hour_time1_entry.get()) + ":" + str(minute_time1_entry.get()) + ":" + str(second_time1_entry.get()) + " " + str(zone_time1_entry.get())
104+
time2 = str(day_time2_entry.get()) + " " + str(date_time2_entry.get()) + " " + str(month_time2_entry.get()) + " " + str(year_time2_entry.get()) + " " + str(hour_time2_entry.get()) + ":" + str(minute_time2_entry.get()) + ":" + str(second_time2_entry.get()) + " " + str(zone_time2_entry.get())
105+
valid = True
106+
day1 = str(day_time1_entry.get())
107+
date1 = int(date_time1_entry.get())
108+
month1 = str(month_time1_entry.get())
109+
year1 = int(year_time1_entry.get())
110+
hour1 = int(hour_time1_entry.get())
111+
minute1 = int(minute_time1_entry.get())
112+
second1 = int(second_time1_entry.get())
113+
114+
day2 = str(day_time2_entry.get())
115+
date2 = int(date_time2_entry.get())
116+
month2 = str(month_time2_entry.get())
117+
year2 = int(year_time2_entry.get())
118+
hour2 = int(hour_time2_entry.get())
119+
minute2 = int(minute_time2_entry.get())
120+
second2 = int(second_time2_entry.get())
121+
122+
if((day1!="Sun" and day1!="Mon" and day1!="Tue" and day1!="Wed" and day1!="Thu" and day1!="Fri" and day1!="Sat") or (day2!="Sun" and day2!="Mon" and day2!="Tue" and day2!="Wed" and day2!="Thu" and day2!="Fri" and day2!="Sat")):
123+
print("day")
124+
valid = False
125+
if((date1<0 or date1>31) or (date2<0 or date2>31)):
126+
# print("date")
127+
valid = False
128+
if ((month1!="Jan" and month1!="Feb" and month1!="Mar" and month1!="Apr" and month1!="May" and month1!="Jun" and month1!="Jul" and month1!="Aug" and month1!="Sep" and month1!="Oct" and month1!="Nov" and month1!="Dec") or (month2!="Jan" and month2!="Feb" and month2!="Mar" and month2!="Apr" and month2!="May" and month2!="Jun" and month2!="Jul" and month2!="Aug" and month2!="Sep" and month2!="Oct" and month2!="Nov" and month2!="Dec")):
129+
# print("month")
130+
valid = False
131+
if(year1<0 or year2<0):
132+
# print("year")
133+
valid = False
134+
if((hour1<0 or hour1>23) or (hour2<0 or hour2>23)):
135+
# print("hour")
136+
valid = False
137+
if ((minute1 < 0 or minute1 > 59) or (minute2 < 0 or minute2 > 59)):
138+
# print("minute")
139+
valid = False
140+
if ((second1 < 0 or second1 > 59) or (second2 < 0 or second2 > 59)):
141+
# print("second")
142+
valid = False
143+
144+
if(valid):
145+
t1 = datetime.strptime(time1, '%a %d %b %Y %H:%M:%S %z')
146+
t2 = datetime.strptime(time2, '%a %d %b %Y %H:%M:%S %z')
147+
mbox.showinfo("Absolute Time Delta", "Time 1 : " + time1 + "\nTime 2 : " + time2 +"\n\nAbsolute Time Delta :\n\nIn seconds : " + str(abs(int((t1 - t2).total_seconds()))))
148+
else:
149+
mbox.showerror("Error", "You have entered wrong input!")
150+
151+
# for getting the sample input
152+
def get_sample():
153+
mbox.showinfo("Sample Time Input", "Sample Time Input :\n\nDay : Sun\nDate : 25\nMonth : Jul\nYear : 2012\nHour : 23\nMinute : 45\nSecond : 46\nTime Zone : +0700")
154+
155+
# creates sample button
156+
sampleb = Button(window, text="SAMPLE",command=get_sample,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
157+
sampleb.place(x =100 , y =650 )
158+
159+
# created delta button
160+
deltab = Button(window, text="ABS. DELTA",command=get_delta,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
161+
deltab.place(x =310 , y =650 )
162+
163+
# created reset function
164+
def reset_label():
165+
day_time1_entry.delete(0, END)
166+
day_time2_entry.delete(0, END)
167+
date_time1_entry.delete(0, END)
168+
date_time2_entry.delete(0, END)
169+
month_time1_entry.delete(0, END)
170+
month_time2_entry.delete(0, END)
171+
year_time1_entry.delete(0, END)
172+
year_time2_entry.delete(0, END)
173+
hour_time1_entry.delete(0, END)
174+
hour_time2_entry.delete(0, END)
175+
minute_time1_entry.delete(0, END)
176+
minute_time2_entry.delete(0, END)
177+
second_time1_entry.delete(0, END)
178+
second_time2_entry.delete(0, END)
179+
zone_time1_entry.delete(0, END)
180+
zone_time2_entry.delete(0, END)
181+
182+
# created reset button
183+
resetb = Button(window, text="RESET",command=reset_label,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
184+
resetb.place(x =570 , y =650 )
185+
186+
# funcion for exiting
187+
def exit_win():
188+
if mbox.askokcancel("Exit", "Do you want to exit?"):
189+
window.destroy()
190+
191+
# created exit button
192+
exitb = Button(window, text="EXIT",command=exit_win,font=("Arial", 20), bg = "red", fg = "blue", borderwidth=3, relief="raised")
193+
exitb.place(x =760 , y =650 )
194+
195+
196+
window.protocol("WM_DELETE_WINDOW", exit_win)
197+
window.mainloop()

0 commit comments

Comments
 (0)