Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c37d8a7

Browse files
Added Distance-Calculator-GUI
1 parent 6eeeec4 commit c37d8a7

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

‎Distance-Calculator-GUI/README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Quick Start:
2+
- Clone this repository.
3+
4+
git clone https://github.com/avinashkranjan/Amazing-Python-Scripts.git
5+
6+
- Change Directory
7+
8+
cd .\Distance-Calculator-GUI\
9+
10+
- Install requirememnts
11+
12+
pip install requirements.txt
13+
14+
- Run python file
15+
16+
python main.py
17+
18+
# Screenshot
19+
20+
![](screenshot/capp.png)

‎Distance-Calculator-GUI/main.py‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from tkinter import *
2+
from geopy.geocoders import Nominatim
3+
from geopy import distance
4+
5+
# user defined funtion
6+
def get_dis():
7+
try:
8+
9+
geolocator = Nominatim(user_agent="geoapiExercises")
10+
11+
place1 = geolocator.geocode(str(e1.get()))
12+
place2 = geolocator.geocode(str(e2.get()))
13+
14+
15+
Loc1_lat,Loc1_lon = (place1.latitude),(place1.longitude)
16+
Loc2_lat,Loc2_lon = (place2.latitude),(place2.longitude)
17+
18+
location1=(Loc1_lat,Loc1_lon)
19+
location2=(Loc2_lat,Loc2_lon)
20+
21+
res = (str(distance.distance(location1, location2).km)+" Km")
22+
23+
result.set(res)
24+
except:
25+
result.set("someting went wrong")
26+
27+
# object of tkinter
28+
# with background set to light grey
29+
master = Tk()
30+
master.configure(bg='light grey')
31+
master.title("Distance Calculating App")
32+
33+
# Variable Classes in tkinter
34+
result = StringVar()
35+
36+
37+
# Creating label for each information
38+
# name using widget Label
39+
Label(master, text="Enter first place : " , bg = "light grey").grid(row=1, sticky=W)
40+
Label(master, text="Enter secound place : " , bg = "light grey").grid(row=2, sticky=W)
41+
42+
Label(master, text="Result :", bg = "light grey").grid(row=3, sticky=W)
43+
44+
# Creating label for class variable
45+
# name using widget Entry
46+
Label(master, text="", textvariable=result,bg = "light grey").grid(row=3,column=1, sticky=W)
47+
48+
49+
e1 = Entry(master,width = 50)
50+
e1.grid(row=1, column=1)
51+
e2 = Entry(master,width = 50)
52+
e2.grid(row=2, column=1)
53+
54+
# creating a button using the widget
55+
b = Button(master, text="Check", command=get_dis, bg = "white")
56+
b.grid(row=1, column=2,columnspan=2, rowspan=2,padx=5, pady=5,)
57+
58+
mainloop()
48 Bytes
Binary file not shown.
17.6 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /