Prerequisite: Tkinter module
In this article, we are going to write python scripts to get sunset and sunrise time and bind it with the GUI application. Before starting we need to understand suntime and geopy module
suntime module: This module will return the sunset and sunrise time calculation python library. Run this command in your terminal for installation.
pip install suntime
geopy module: This module locates the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources. Nominatim is a geocoder that is used for OpenStreetMap data. Run this command in your terminal for installation.
pip install geopy
- Import all the required modules.
- Get latitude and longitude with geopy.
- Get the Sunrise time with Sun(latitude, longitude).get_sunrise_time() method.
- Get the dusk time with Sun(latitude, longitude).get_sunset_time() method.
Below is the Implementation:
Sun rise at : 06:05 Dusk at : 18:28
Binding with GUI application
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course