-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script.py
66 lines (51 loc) · 1.75 KB
/
Script.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
from tkinter import *
from geopy.geocoders import Nominatim
from timezonefinder import TimezoneFinder
from datetime import datetime
import pytz
def find():
s=e1.get()
l=Nominatim(user_agent="geoapiExcercise")
x=l.geocode(s)
tz=TimezoneFinder()
lat=x.latitude
long=x.longitude
s1=tz.timezone_at(lng=long, lat=lat)
t=pytz.timezone(s1)
dt=datetime.now(t)
if dt.hour<12:
time=str(dt.hour)+":"+str(dt.minute)+":"+str(dt.second)+" AM"
elif dt.hour>12:
w=dt.hour-12
time=str(w)+":"+str(dt.minute)+":"+str(dt.second)+" PM"
else:
time=str(dt.hour)+":"+str(dt.minute)+":"+str(dt.second)+" PM"
e2.delete(first=0,last=len(e2.get()))
e2.insert(END,str(s1))
e3.delete(first=0,last=len(e3.get()))
e3.insert(END,str(time))
window=Tk()
window.title("Know Your Time")
window.resizable(0,0)
l1=Label(window,text="Know Your Time",font=("Arial",25))
l1.grid(row=0,column=0,columnspan=3)
l2=Label(window,text="Enter the Place ",font=("Arial",18))
l2.grid(row=1,column=0)
e1_val=StringVar()
e1=Entry(window,textvariable=e1_val,font=("Arial",18))
e1.grid(row=1,column=1)
b=Button(window,text="Go",font=("Arial",14),command=find)
b.grid(row=1,column=2)
l_blank=Label(window,text="",font=5)
l_blank.grid(row=2,column=0,columnspan=3)
l3=Label(window,text="Time Zone",font=("Arial",18))
l3.grid(row=3,column=0)
e2_val=StringVar()
e2=Entry(window,textvariable=e2_val,font=("Arial",18),width=24)
e2.grid(row=3,column=1,columnspan=2)
l4=Label(window,text="Time",font=("Arial",18))
l4.grid(row=4,column=0)
e3_val=StringVar()
e3=Entry(window,textvariable=e3_val,font=("Arial",18),width=24)
e3.grid(row=4,column=1,columnspan=2)
window.mainloop()