This is a simple Tkinter-based GUI application that calculates the distance between two locations. Users can input start and end locations, and the application fetches the geographic coordinates for these locations using the Nominatim API. It then calculates the geodesic distance between the coordinates and displays the result in kilometers.
- Input start and end locations.
- Fetch geographic coordinates using the Nominatim API.
- Calculate the geodesic distance between two locations.
- Switch start and end locations.
- Exit the application gracefully.
Make sure you have Python installed on your system. You also need to install the following Python libraries:
geopyrequestspillow(for handling images, if required)
You can install these libraries using pip:
pip install geopy requests pillow- Clone the repository to your local machine:
git clone https://github.com/your-username/distance-calculator.git- Navigate to the project directory:
cd distance-calculator-
Ensure you have an image file named
arrow.pngin the project directory or update the code to point to the correct path of your arrow image. -
Run the application:
python distance_calculator.pyThe main script distance_calculator.py includes the following key functions:
get_coordinates(address): Fetches the geographic coordinates (latitude and longitude) for a given address using the Nominatim API.calculate_distance(): Calculates the geodesic distance between the start and end locations entered by the user.switch_points(): Switches the values between the start and end location entry widgets.
The GUI is built using Tkinter and includes:
- Labels and entry widgets for start and end locations.
- A switch button to swap the start and end locations.
- A button to calculate the distance.
- A result label to display the calculated distance.
- An exit button to close the application.
This project is free to use.
Contributions are welcome! Please feel free to submit a Pull Request.
- This application uses the Nominatim API from OpenStreetMap for geocoding.
- Distance calculations are performed using the
geopylibrary.