Skip to content

Commit 9392c1b

Browse files
Merge pull request prathimacode-hub#437 from akash435/locbranch
Added Get Location of any Country in GUIScripts
2 parents 6f7c279 + 4854ce9 commit 9392c1b

File tree

12 files changed

+413
-0
lines changed

12 files changed

+413
-0
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ✔ GET LOCATION OF ANY COUNTRY
2+
- ### A "Get location of any country" is an application created in python with tkinter gui.
3+
- ### In this application, user can find the location of any country, either by using country name or country code.
4+
- ### The location will be shown in terms of Latitude and Longitude.
5+
- ### for the data, used the world_location.csv data, and read using pandas library.
6+
7+
****
8+
9+
# REQUIREMENTS :
10+
- ### python 3
11+
- ### tkinter module
12+
- ### from tkinter messagebox module
13+
- ### pandas
14+
15+
****
16+
17+
# How this Script works :
18+
- ### User just need to download the file and run the get_location_by_any_country.py on their local system.
19+
- ### Now on the main window of the application the user needs to select either the country code or the country name from the drop down OptionMenu.
20+
- ### After user has chosen the country code, when user clicks on the BY CODE button, he/she will be able to see the location in the message box in terms of Latitude and Longitude.
21+
- ### Abd after user has chosen the country name, when user clicks on the BY COUNTRY button, he/she will be able to see the location in the message box.
22+
- ### Also there is a reset button, clicking on which user can resets both the Option Menu to default character ot integer.
23+
- ### Also there is an exit button, clicking on which exit dialog box appears asking for the permission of the user for closing the window.
24+
25+
****
26+
27+
# SCREENSHOTS :
28+
29+
****
30+
31+
<p align="center">
32+
<img width = 700 src="Images/1.jpg" /><br>
33+
<img width = 700 src="Images/2.jpg" /><br>
34+
<img width = 700 src="Images/3.jpg" /><br>
35+
<img width = 700 src="Images/4.jpg" /><br>
36+
<img width = 700 src="Images/5.jpg" /><br>
37+
<img width = 700 src="Images/6.jpg" /><br>
38+
<img width = 700 src="Images/7.jpg" /><br>
39+
</p>
40+
41+
****
42+
43+
# Below is the video links of how appliation works :
44+
https://user-images.githubusercontent.com/57003737/122977771-6a3e3300-d3b3-11eb-913d-b33939bb166f.mp4
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
2+
# Time Zone Converter
3+
4+
import tkinter
5+
from tkinter import *
6+
import tkinter as tk
7+
import tkinter.messagebox as mbox
8+
import pandas as pd
9+
10+
11+
12+
window = Tk()
13+
window.geometry("1000x700")
14+
window.title("COUNTRY LOCATION")
15+
16+
# ---------------------------------------------------------
17+
frameCnt = 4
18+
frames = [PhotoImage(file='Images/latlong.gif',format = 'gif -index %i' %(i)) for i in range(frameCnt)]
19+
20+
cnt = 0.0
21+
def update(ind):
22+
global cnt
23+
frame = frames[ind]
24+
if(cnt == 1.0):
25+
cnt = 0
26+
cnt = cnt + 0.2
27+
ind += int(cnt)
28+
if ind == frameCnt:
29+
ind = 0
30+
label.configure(image=frame)
31+
window.after(100, update, ind)
32+
label = Label(window)
33+
label.place(x = 130, y = 100)
34+
window.after(0, update, 0)
35+
# --------------------------------------------------------------------
36+
37+
data = pd.read_csv("world_location.csv")
38+
country_code = data["country_code"].tolist()
39+
country = data["country"].tolist()
40+
latitude = data["latitude"].tolist()
41+
longitude = data["longitude"].tolist()
42+
43+
# print(country_code)
44+
# print(country)
45+
# print(latitude)
46+
# print(longitude)
47+
48+
def get_location_code():
49+
code = code_var.get()
50+
for i in range(0, len(country_code)):
51+
if(country_code[i] == code):
52+
mbox.showinfo("Location By Code", "Location of Country with code : "+ str(code) + "\n\nLatitude : " + str(latitude[i]) + "\n\nLongitude : " + str(longitude[i]))
53+
54+
def get_location_country():
55+
country1 = country_var.get()
56+
for i in range(0, len(country)):
57+
if(country[i] == country1):
58+
mbox.showinfo("Location By Country", "Location of Country with Name : "+ str(country1) + "\n\nLatitude : " + str(latitude[i]) + "\n\nLongitude : " + str(longitude[i]))
59+
60+
61+
# top label
62+
start1 = tk.Label(text = "COUNTRY LOCATION", font=("Arial", 50), fg="magenta",underline=0) # same way bg
63+
start1.place(x = 150, y = 10)
64+
65+
# label for country code ---------------------------------------------------------------------------------
66+
codelbl = tk.Label(text = "Get By Country Code : ", font=("Arial", 30), fg="brown") # same way bg
67+
codelbl.place(x = 200, y = 460)
68+
69+
# creating the drop down menu button for selectng hour
70+
code_var = tk.StringVar()
71+
# as icon size are really small, we defined the following 7 sizes
72+
# first_choices = ["GMT", "UTC", "ECT", "EET", "ART", "EAT", "MET", "NET", "PLT", "IST", "BST", "VST", "CTT", "JST", "ACT", "AET","SST", "NST", "MIT", "HST", "AST", "PST", "PNT", "MST", "CST", "EST", "IET", "PRT", "CNT", "AGT", "BET", "CAT"]
73+
code_choices = country_code
74+
# first_choices.sort()
75+
code_menu = OptionMenu(window, code_var, *code_choices)
76+
code_menu.config(font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3)
77+
code_menu["menu"].config(font=("Arial", 10), bg = "light yellow", fg = "blue")
78+
code_menu.place(x=610, y=460)
79+
code_var.set("IN") # size 1 is selected as by default, and we can
80+
81+
# label for country code ---------------------------------------------------------------------------------
82+
countrylbl = tk.Label(text = "Get By Country Name : ", font=("Arial", 30), fg="brown") # same way bg
83+
countrylbl.place(x = 150, y = 530)
84+
85+
# creating the drop down menu button for selectng hour
86+
country_var = tk.StringVar()
87+
# as icon size are really small, we defined the following 7 sizes
88+
# first_choices = ["GMT", "UTC", "ECT", "EET", "ART", "EAT", "MET", "NET", "PLT", "IST", "BST", "VST", "CTT", "JST", "ACT", "AET","SST", "NST", "MIT", "HST", "AST", "PST", "PNT", "MST", "CST", "EST", "IET", "PRT", "CNT", "AGT", "BET", "CAT"]
89+
country_choices = country
90+
# first_choices.sort()
91+
country_menu = OptionMenu(window, country_var, *country_choices)
92+
country_menu.config(font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3)
93+
country_menu["menu"].config(font=("Arial", 10), bg = "light yellow", fg = "blue")
94+
country_menu.place(x=570, y=530)
95+
country_var.set("India") # size 1 is selected as by default, and we can
96+
97+
getb1 = Button(window, text="BY CODE",command=get_location_code,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
98+
getb1.place(x =100 , y =600 )
99+
100+
getb2 = Button(window, text="BY COUNTRY",command=get_location_country,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
101+
getb2.place(x =300 , y =600 )
102+
103+
def reset_label():
104+
code_var.set("IN")
105+
country_var.set("India")
106+
107+
resetb = Button(window, text="RESET",command=reset_label,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
108+
resetb.place(x =560 , y =600 )
109+
110+
111+
def exit_win():
112+
if mbox.askokcancel("Exit", "Do you want to exit?"):
113+
window.destroy()
114+
115+
exitb = Button(window, text="EXIT",command=exit_win,font=("Arial", 20), bg = "red", fg = "blue", borderwidth=3, relief="raised")
116+
exitb.place(x =730 , y =600 )
117+
118+
119+
window.protocol("WM_DELETE_WINDOW", exit_win)
120+
window.mainloop()

0 commit comments

Comments
 (0)