예제 #1
0
def get_country_coord(country):
    country_off = pycountry.countries.search_fuzzy(country)[0].official_name
    c = CountryInfo(country_off)
    try:
        capital = c.capital()
    except KeyError:
        capital = CountryInfo(country).capital()
    return (get_country_city_coord(country, capital))
예제 #2
0
def capital(message):
    message = message.replace('!capital ', '')
    message = message.replace('!capital', '')
    if message == '':
        return 'Please specify country.'
    else:
        countryinfo = CountryInfo(message)
        message = message.replace(message[0], message[0].upper())
        message = message.replace(message[1:], message[1:].lower())
        return "The capital of " + message + " is " + str(
            countryinfo.capital() + ".")
예제 #3
0
def get_capital():
    with sr.Microphone() as source:
        print("What country would you like to know the capital of: ")
        audio = r.listen(source)
    try:
        country_said = r.recognize_google(audio)
    except:
        print("Could not recognize your voice")
    try:
        country = CountryInfo(country_said)
        print("The capital of " + country_said + " is " + country.capital() + ".")
예제 #4
0
def user_geo(country_name="me"):
    if country_name == "me":
        code = geocoder.ip(country_name).country
        country = CountryInfo(code)
    else:
        country = CountryInfo(country_name)
        code = country.iso(2)
    capital = country.capital()
    name = country.name().capitalize()
    currency = country.currencies()
    return [code, name, capital, currency]
예제 #5
0
파일: bot2.py 프로젝트: Lalitha-12/Ml2021
def capital():
    i = 1
    while i > 0:
        a = input("Enter country name: ")
        if (a == "bye"):
            break
        else:
            s = a
            country = CountryInfo(s)
            print(country.capital())
            #it prints the capital of country
            print(country.currencies())
            #it prints currency of country
        i = i + 1
예제 #6
0
def country_info(country_name):
    d = []
    country = CountryInfo(country_name)
    d.append(["name", country.name().capitalize()])
    d.append(["capital", country.capital().capitalize()])
    d.append(["region", country.region().capitalize()])
    d.append(["currency", country.currencies()])
    d.append(["area", country.area()])
    d.append(["population", country.population()])
    d.append(["languages", country.languages()])
    d.append(["borders", country.borders()])
    d.append(["calling code", country.calling_codes()])
    d.append(["lat/long", country.capital_latlng()])
    d.append(["code", country.iso(2)])
    return d
def capitales_etudiee_oecd():
    '''
    Enable to retrieve OECD countries capitals through CountryInfo() method.
    This is useful for OpenWeatherMap informations extracting.

    ==> Countries capitals are return in a dictionnary as follows:
    {
    ...
    'SRI LANKA': 'Colombo',
    'SUDAN': 'Khartoum', etc
    ...
    }

    '''
    with open('app/static/json/city.list.json') as f:
        data = json.load(f)
    capitales_oecd = {}
    nom_pays_ocde_majuscules = []
    nom_pays_open_weather_majuscules = []
    pays_communs_pour_projet = []

    for pays in nom_des_pays:
        nom_pays_ocde_majuscules.append(pays.upper())
    infos_pays = CountryInfo()
    infos_pays = infos_pays.all()
    infos_pays = dict(infos_pays)

    for pays in infos_pays.keys():
        nom_pays_open_weather_majuscules.append(pays.upper())

    ### Creation of a set in order to find similar cities within lists
    pays_ocde = set(nom_pays_ocde_majuscules)
    pays_open_weather = set(nom_pays_open_weather_majuscules)
    pays_communs_pour_projet = pays_ocde.intersection(pays_open_weather)

    ### Converting set in list
    pays_communs_pour_projet = list(pays_communs_pour_projet)
    pays_communs_pour_projet.sort(reverse=False)

    for pays in pays_communs_pour_projet:
        country = CountryInfo(pays)
        # capitale = country.capital().upper()
        capitale = country.capital()
        capitales_oecd[pays] = capitale

    return capitales_oecd
예제 #8
0
async def get_location(addr: str):
    async with Nominatim(
            user_agent="MuslimBot",
            adapter_factory=AioHTTPAdapter,
    ) as geolocator:
        try:
            location = await geolocator.geocode(addr, addressdetails=True)
        except geopy.exc.GeocoderTimedOut:
            raise ValueError("Could not find location!")
        if location is None:
            raise ValueError("Invalid address!")
        location = location.raw["address"]
        country = location.get("country")
        if country is None:
            raise ValueError("Country not found!")
        city = location.get("city")
        village = location.get("village")
        if city is not None:
            return city, country
        elif village is not None:
            return village, country
        else:
            c = CountryInfo(addr)
            return c.capital(), addr
예제 #9
0
import qrcode
import folium
from countryinfo import CountryInfo

print('Welcome, You can get information about any country here!')
user = input('\nEnter the name of a country:\n')
name = user

country = CountryInfo(name)

country_name = country.alt_spellings()
print('\nName:')
for name in country_name:
    print(name, end=', ')

country_capital = country.capital()
print(f'\n\nCapital:\n{country_capital}')

country_currency = country.currencies()
print('\nCurrency:')
for currency in country_currency:
    print(currency, end=', ')

country_lang = country.languages()
print('\n\nLanguages:')
for languages in country_lang:
    print(languages, end=', ')

country_timezone = country.timezones()
print('\n\nTime-Zone:')
for timezones in country_timezone:
예제 #10
0
        if category == "area":
            print('(' + choices[x] + ') ' + str(country_choice.area()) +
                  " sq kilometers")

        elif category == "subregion":
            print('(' + choices[x] + ') ' + subregion_pool[x])

        elif category == "calling code":
            print('(' + choices[x] + ') ' +
                  str(country_choice.calling_codes()[0]))

        elif category == "population":
            print('(' + choices[x] + ') ' + str(country_choice.population()))

        elif category == "capital":
            print('(' + choices[x] + ') ' + country_choice.capital())

        elif category == "currency":
            print('(' + choices[x] + ') ' + currencies_pool[x])

        elif category == "latitude":
            print('(' + choices[x] + ') ' + str(country_choice.latlng()[0]))

        elif category == "longitude":
            print('(' + choices[x] + ') ' + str(country_choice.latlng()[1]))

    answer_user = input("\nPlease choose an option: ")
    while answer_user not in choices[0:options[category_index]]:
        answer_user = input("Please choose a valid option: ")

    if answer_user == answer:
def get_capital_by_country(country):
    country = CountryInfo(country)
    return country.capital()
예제 #12
0
'''
Fetch data of any Country with Python using Countryinfo
Author: Ayushi Rawat
'''

#import the necessary module!
from countryinfo import CountryInfo

name = 'India'
country = CountryInfo(name)

data1 = country.alt_spellings()
print(data1)

data2 = country.capital()
print(data2)

data3 = country.currencies()
print(data3)

data4 = country.languages()
print(data4)

data5 = country.timezones()
print(data5)

data6 = country.area()
print(data6)

data7 = country.borders()
print(data7)
예제 #13
0
from countryinfo import CountryInfo
import sys

country = sys.argv[1]
country_obj = CountryInfo(country)

caps = {'New Mexico': 'Santa Fe', 'Colorado': 'Denver', 'Vermont': 'Montpelier', 'Arizona': 'Phoenix', 'Iowa': 'Des Moines', 'Florida': 'Tallahassee', 'West Virginia': 'Charleston', 'Illinois': 'Springfield', 'Oregon': 'Salem', 'Kansas': 'Topeka', 'Arkansas': 'Little Rock', 'Kentucky': 'Frankfort', 'Massachusetts': 'Boston', 'Texas': 'Austin', 'Wyoming': 'Cheyenne', 'Maryland': 'Annapolis', 'New York': 'Albany', 'New Jersey': 'Trenton', 'Louisiana': 'Baton Rouge', 'South Carolina': 'Columbia', 'Georgia': 'Atlanta', 'Idaho': 'Boise', 'Alaska': 'Juneau', 'Oklahoma': 'Oklahoma City', 'Connecticut': 'Hartford', 'Nebraska': 'Lincoln', 'Tennessee': 'Nashville', 'Pennsylvania': 'Harrisburg', 'Michigan': 'Lansing', 'Maine': 'Augusta', 'Wisconsin': 'Madison', 'South Dakota': 'Pierre', 'California': 'Sacramento', 'New Hampshire': 'Concord', 'Indiana': 'Indianapolis', 'Washington': 'Olympia', 'Utah': 'Salt Lake City', 'Alabama': 'Montgomery', 'Minnesota': 'St. Paul', 'Hawaii': 'Honolulu', 'Ohio': 'Columbus', 'Missouri': 'Jefferson City', 'Delaware': 'Dover', 'Virginia': 'Richmond', 'Nevada': 'Carson City', 'Montana': 'Helena', 'North Dakota': 'Bismarck', 'Mississippi': 'Jackson', 'North Carolina': 'Raleigh', 'Rhode Island': 'Providence', 'Bahamas': 'Nassau', 'Andorra': 'Andorra la Vella', 'East Timor (Timor-Leste)': 'Dili', 'Serbia': 'Belgrade', 'Macedonia': 'Skopje', 'Gambia': 'Banjul'}

# with open('usstates.csv', 'r') as f:
#     for l in f:
#         l = l.strip()
#         state, cap = l.split(',')
#         caps[state] = cap


try:
    if country == 'Georgia':
        print(caps['Georgia'])
    elif country == 'San Marino':
        print('San Marino')
    elif country == 'Kiribati':
        print('Tarawa')
    elif country == 'Moldova':
        print('Chisinau')
    else:
        print(country_obj.capital())
except KeyError:
    print(caps[country])
예제 #14
0
def main():

    # Main Program
    greeting()
    query = takecommand().lower()

    # Execution of basic tasks

    if 'wikipedia' in query:
        speak('Searching wikipedia...')
        query = query.replace("wikipedia", "")
        results = wikipedia.summary(query, sentences=2)
        print(results)
        speak("According to wikipedia" + results)

    elif "directions" in query or "map" in query or "direction" in query:
        speak("Ok, what is the starting location?")
        start = takecommand()
        speak("Thanks, what is the destination?")
        end = takecommand()
        webbrowser.open_new_tab("https://www.google.ca/maps/dir/" + start +
                                "/" + end)

    elif "emoji" in query:
        emoji = input('Write emoji: ')
        a = emoji.split()
        emojis = {
            ':)': '😀',
            ':(': '😟',
            ';)': '😉',
            '<3': '♥',
            '¯\_( ͡� ͜ʖ ͡�)_/¯': '🤷�'
        }

        output = ""

        speak("Please write emoji to convert")

        for words in a:
            output += emojis.get(words, words) + ' '
            pyperclip.copy(output)
        print("Emoji Copied!")

    elif "search google" in query or "google search" in query:
        query = query.replace("search", "")
        query = query.replace("google", "")
        query = query.replace("for", "")
        webbrowser.open("https://google.com/search?q=%s" % query)

    elif "search youtube" in query or "youtube search" in query:
        query = query.replace("search", "")
        query = query.replace("youtube", "")
        query = query.replace("for", "")
        webbrowser.open("https://www.youtubekids.com/search?q=%s" % query)

    elif "+" in query:
        words = query.lower().split()
        num1 = int(words[words.index('+') - 1])
        num2 = int(words[words.index('+') + 1])
        print(str(num1) + " + " + str(num2) + " = " + str(num1 + num2))

    elif "-" in query:
        words = query.lower().split()
        num1 = int(words[words.index('-') - 1])
        num2 = int(words[words.index('-') + 1])
        print(str(num1) + " - " + str(num2) + " = " + str(num1 - num2))

    elif "*" in query:
        words = query.lower().split()
        num1 = int(words[words.index('*') - 1])
        num2 = int(words[words.index('*') + 1])
        print(str(num1) + " x " + str(num2) + " = " + str(num1 * num2))

    elif "/" in query:
        words = query.lower().split()
        num1 = int(words[words.index('/') - 1])
        num2 = int(words[words.index('/') + 1])
        print(str(num1) + " ÷ " + str(num2) + " = " + str(num1 / num2))

    elif "password" in query:
        speak("Are special charecters allowed?")
        special_chars = takecommand()
        if special_chars == "yes":
            chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&*"

        else:
            chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        speak("What is the length of the password?")
        length = int(takecommand())
        password = ''
        for c in range(length):
            password += random.choice(chars)
        pyperclip.copy(password)
        print(password + " is Copied!")

    elif "shopping list" in query:
        print("This is your current shopping list: " + str(shopping_list))
        question = takecommand()
        if question == "yes" or question == "y":
            new_item = str(takecommand())
            new_item = new_item.split(" and ")
            shopping_list.append(new_item)
            print("This is your new shopping list: " + str(shopping_list))

        else:
            speak("ok")

    elif "weather" in query or "what's the weather" in query:
        api_key = "http://api.openweathermap.org/data/2.5/weather?q=" + your_city + "&appid=" + api_key
        json_data = requests.get(api_key).json()
        description = json_data['weather'][0]['description']
        temperature = int(json_data['main']['temp'])
        cel = str(int(temperature - 273.15))
        if description == "broken clouds":
            print("it is " + cel + " degrees celsius with " + description)
            speak("it is " + cel + " degrees celsius with " + description)

        else:
            print("it is " + cel + " degrees celsius with a " + description)
            speak("it is " + cel + " degrees celsius with a " + description)

    elif "capital of" in query:
        word_list = query.split()
        country = CountryInfo(word_list[-1])
        capital_city = str(country.capital())
        print(capital_city)
        speak("It's capital is" + capital_city)

    elif "synonym" in query:
        query = query.replace("synonym", "")
        query = query.replace("what is", "")
        query = query.replace("the", "")
        query = query.replace("of", "")
        dictionary = PyDictionary()
        print(dictionary.synonym(query))
        speak(dictionary.synonym(query))

    elif "define" in query or "definition" in query:
        query = query.replace("definition", "")
        query = query.replace("define", "")
        query = query.replace("what is", "")
        query = query.replace("the", "")
        query = query.replace("of", "")
        dictionary = PyDictionary()
        print(dictionary.meaning(query))
        speak(dictionary.meaning(query))

    elif "what is your name" in query:
        speak("My name is Jarvis, sir")

    elif 'open youtube' in query:
        url = "www.youtube.com"
        chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
        speak("Opening youtube")
        webbrowser.get(chrome_path).open(url)

    elif 'open google' in query:
        url = "chrome://newtab/"
        chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
        speak("Opening google")
        webbrowser.get(chrome_path).open_new_tab(url)

    elif 'time' in query:
        current_time = datetime.datetime.now().strftime("%I:%M %p")
        formatted_time = datetime.datetime.now().strftime("%H %M")
        print(current_time)
        speak(master + "the time is" + formatted_time)

    elif 'hey jarvis' in query or 'hey' in query:
        speak("Hello" + master + ", I am here if you need me.")

    elif 'how are you' in query:
        speak("I am great, how about you?")

    elif "i'm good" in query or "i'm great" in query:
        speak("That's great I'm doing fine too.")

    elif "i'm doing bad" in query:
        speak("What happened, sir")

    elif "open calculator" in query:
        subprocess.Popen('C:\\Windows\\System32\\calc.exe')

    else:
        speak("Sorry I can't do that yet")
예제 #15
0
def get_capital(country):
    """Returns Country Capital."""
    country = CountryInfo(country)
    return country.capital()
예제 #16
0
            def sat_city_info():
                ''' Function to define or update the current information for the remote or 'sat' city location,
                pulling the recent data from the api '''
                self.sat_city = city2_entry.get()
                print(f"Getting weather data for {self.sat_city}....")
                if weatherapp.init_counter == False:
                    weatherapp.button = True
                utc = pytz.timezone('UTC')
                # API Call
                sat_api_request = requests.get(
                    "https://api.openweathermap.org/data/2.5/weather?q=" +
                    self.sat_city + "&units=imperial&appid=" + self.api_key)
                if sat_api_request.status_code != 200:
                    messagebox.showwarning(
                        "Weather App Warning",
                        f"HTTP Status code for API request to '{self.sat_city}' is "
                        f"{sat_api_request.status_code}. \n"
                        f"Please check your spelling and try again.")
                    print(
                        f"{self.sat_city} API HTTP Status code is {sat_api_request.status_code}."
                    )
                    raise KeyError
                else:
                    sat_api = json.loads(sat_api_request.content)

                # Satellite City Temperatures
                a = sat_api['main']
                current_temperature2 = a['temp']
                humidity2 = a['humidity']
                tempmin2 = a['temp_min']
                tempmax2 = a['temp_max']

                # Satellite City Icon
                b = sat_api['weather']
                icon2 = [dict['icon'] for dict in b]
                icon2 = ''.join(icon2)
                descrip2 = ', '.join([dict['description']
                                      for dict in b]).title()
                if len(descrip2) >= 16:
                    descrip2 = descrip2[0:14]
                icon_url2 = f"http://openweathermap.org/img/wn/{icon2}@2x.png"

                # Satellite City Coordinates
                c = sat_api['coord']
                longitude2 = c['lon']
                latitude2 = c['lat']

                # Satellite City Country & daylight information
                d = sat_api['sys']
                country2 = d['country']
                sat_sunrise = d['sunrise']
                sat_sunrise = datetime.datetime.fromtimestamp(sat_sunrise)
                self.sat_sunrise = sat_sunrise
                sat_sunset = d['sunset']
                sat_sunset = datetime.datetime.fromtimestamp(sat_sunset)
                self.sat_sunset = sat_sunset

                # Satellite City
                citi2 = sat_api['name']

                # Satellite Timezone via offset and dict search
                sat_timeoffset = sat_api['timezone']
                sat_timeoffset = datetime.timedelta(seconds=sat_timeoffset)
                sat_now = datetime.datetime.now(pytz.utc)
                sat_countryname = country_alpha2_to_country_name(country2)
                sat_capital = CountryInfo(sat_countryname)
                sat_capital = sat_capital.capital()
                if sat_countryname == 'United States':
                    sat_countryname = 'America'
                sat_offset_matches = [
                    tz.zone
                    for tz in map(pytz.timezone, pytz.all_timezones_set)
                    if sat_now.astimezone(tz).utcoffset() == sat_timeoffset
                ]
                if len(sat_offset_matches) > 1:
                    sat_firstchoice, sat_secondchoice = [], []
                    try:
                        print(f'Searching for {citi2}....')
                        sat_firstchoice += [
                            listitem for listitem in sat_offset_matches
                            if citi2 in listitem
                        ]
                    except:
                        pass
                    try:
                        print(f'Searching for {country2}....')
                        sat_firstchoice += [
                            listitem for listitem in sat_offset_matches
                            if country2 in listitem
                        ]
                    except:
                        pass
                    if len(sat_firstchoice) == 0:
                        try:
                            print(f'Searching for {sat_capital}....')
                            sat_firstchoice += [
                                listitem for listitem in sat_offset_matches
                                if sat_capital in listitem
                            ]
                        except:
                            pass
                    try:
                        print(f'Searching for {sat_countryname}....')
                        sat_firstchoice += [
                            listitem for listitem in sat_offset_matches
                            if sat_countryname in listitem
                        ]
                    except:
                        pass
                    if len(sat_firstchoice) >= 2:
                        try:
                            print(f'Searching for {citi2}....')
                            sat_secondchoice += [
                                listitem for listitem in sat_firstchoice
                                if citi2 in listitem
                            ]
                            if sat_secondchoice != '':
                                sat_firstchoice.insert(0, sat_secondchoice[0])
                            else:
                                print(f"City {citi2} not found!")
                            sat_secondchoice += [
                                listitem for listitem in sat_firstchoice
                                if sat_capital in listitem
                            ]
                            if sat_secondchoice != '':
                                sat_firstchoice.insert(0, sat_secondchoice[0])
                            else:
                                print(f"Capital city {sat_capital} not found!")
                        except:
                            pass
                    if len(sat_firstchoice) == 0:
                        sat_firstchoice = sat_offset_matches
                    print(f'Available timezones: {sat_firstchoice}.')
                    sat_zone = ''.join(sat_firstchoice[0])
                    print(f'Picked timezone: {sat_zone}.')
                else:
                    sat_zone = ''.join(sat_offset_matches)
                sat_zone = pytz.timezone(sat_zone)
                sat_sunrise = sat_sunrise.astimezone(sat_zone)
                sat_sunset = sat_sunset.astimezone(sat_zone)

                # Satellite Date & Time converted from UNIX timestamp to UTC and then to Local
                sat_dt = sat_api['dt']
                sat_dt = datetime.datetime.fromtimestamp(sat_dt)
                sat_utc_dt = sat_dt.astimezone(utc)
                sat_dt = sat_utc_dt.astimezone(sat_zone)
                sat_dt = sat_dt.astimezone(sat_zone)
                sat_date = sat_dt.strftime('%d %B, %Y')
                sat_time = sat_dt.strftime('%H:%M (%p)')

                # Update the information labels
                label_temp2.configure(
                    text=f"Temperature: {current_temperature2}" + '\u00b0')
                label_humidity2.configure(text=f"Humidity: {humidity2}%")
                max_temp2.configure(text="Max Temp Today: " + f"{tempmax2}" +
                                    '\u00b0')
                min_temp2.configure(text=f"Min Temp Today: {tempmin2}\u00b0")
                label_lon2.configure(text=f"Longitude: {longitude2}" +
                                     '\u00b0')
                label_lat2.configure(text=f"Latitude: {latitude2}" + '\u00b0')
                label_citi2.configure(text=f"{citi2}, {country2}")
                label_descrip2.configure(text=f"Weather: {descrip2}")
                label_time2.configure(text=f"Local Time: {sat_time}")
                label_date2.configure(text=f"{sat_date}")

                # Download and save the appropriate weather icon
                try:
                    print(f"Trying to download icon from: {icon_url2}.")
                    r = requests.get(icon_url2, stream=True)
                    if r.status_code == 200:
                        r.raw.decode_content = True
                        with open(icon2, "wb") as f:
                            shutil.copyfileobj(r.raw, f)
                        print(f"Downloaded image: {icon2}.")
                        weatherapp.sat_image = ImageTk.PhotoImage(
                            Image.open(icon2))
                    else:
                        print(
                            f"Received HTTP status code {r.status_code} while trying to download {icon2}."
                        )
                        weatherapp.sat_image = ImageTk.PhotoImage(
                            Image.open(resource_path('img_notfound.jpeg')))
                except Exception as error:
                    print(f"Error occured with downloading {icon2}: {error}.")
                    weatherapp.sat_image = ImageTk.PhotoImage(
                        Image.open(resource_path('img_notfound.jpeg')))

                # Icon Placement
                label_icon2 = tkinter.Label(weatherapp,
                                            bg='white',
                                            image=weatherapp.sat_image)
                label_icon2.place(x=((self.w / 2) + 75), y=303)

                # Image application
                if sat_dt >= sat_sunrise:
                    if sat_dt <= sat_sunset:
                        print(f"In {self.sat_city} it is currently daytime.")
                        weatherapp.day_night2 = weatherapp.day
                    else:
                        print(f"In {self.sat_city} it is currently nighttime.")
                        weatherapp.day_night2 = weatherapp.night
                else:
                    print(f"In {self.sat_city} it is currently nighttime.")
                    weatherapp.day_night2 = weatherapp.night

                # Theme for the respective time the application is used
                weatherapp.sat_day_night_panel = tkinter.Label(
                    weatherapp, bg='white', image=weatherapp.day_night2)
                weatherapp.sat_day_night_panel.place(x=((self.w / 2) + 35),
                                                     y=225)
예제 #17
0
            def cur_city_info():
                ''' Function to define or update the current information for the current or 'cur' city location,
                pulling the recent data from the api '''
                self.cur_city = city1_entry.get()
                print(f"Getting weather data for {self.cur_city}....")
                if weatherapp.init_counter == False:
                    weatherapp.button = True
                utc = pytz.timezone('UTC')
                # API Call
                cur_api_request = requests.get(
                    "https://api.openweathermap.org/data/2.5/weather?q=" +
                    self.cur_city + "&units=imperial&appid=" + self.api_key)
                if cur_api_request.status_code != 200:
                    messagebox.showwarning(
                        "Weather App Warning",
                        f"HTTP Status code for API request to '{self.cur_city}' is "
                        f"{cur_api_request.status_code}. \n"
                        f"Please check your spelling and try again.")
                    print(
                        f"{self.cur_city} API HTTP Status code is {cur_api_request.status_code}."
                    )
                    raise KeyError
                else:
                    cur_api = json.loads(cur_api_request.content)

                # Current City Temperatures
                z = cur_api['main']
                current_temperature1 = z['temp']
                humidity1 = z['humidity']
                tempmin1 = z['temp_min']
                tempmax1 = z['temp_max']

                # Current City Icon
                y = cur_api['weather']
                icon1 = [dict['icon'] for dict in y]
                icon1 = ''.join(icon1)
                descrip1 = ', '.join([dict['description']
                                      for dict in y]).title()
                if len(descrip1) >= 16:
                    descrip1 = descrip1[0:14]
                icon_url1 = f"http://openweathermap.org/img/wn/{icon1}@2x.png"

                # Current City Coordinates
                x = cur_api['coord']
                longitude1 = x['lon']
                latitude1 = x['lat']

                # Current City
                citi1 = cur_api['name']

                # Current City Country & daylight information
                v = cur_api['sys']
                country1 = v['country']
                cur_sunrise = v['sunrise']
                cur_sunrise = datetime.datetime.fromtimestamp(cur_sunrise)
                self.cur_sunrise = cur_sunrise
                cur_sunset = v['sunset']
                cur_sunset = datetime.datetime.fromtimestamp(cur_sunset)
                ''' Current Timezone via offset and dict search - note that getting the timezone perfectly right 
                doesn't really matter as long as the offset is correct. However, because precision is important, 
                we will get as reasonably close as possible here without correcting for spaces, colloquial countrynames,
                using state capitals or population centers to identify timezones, etc. '''

                cur_timeoffset = cur_api['timezone']
                cur_timeoffset = datetime.timedelta(seconds=cur_timeoffset)
                cur_now = datetime.datetime.now(pytz.utc)
                cur_countryname = country_alpha2_to_country_name(country1)
                cur_capital = CountryInfo(cur_countryname)
                cur_capital = cur_capital.capital()
                if cur_countryname == 'United States':
                    cur_countryname = 'America'
                cur_offset_matches = [
                    tz.zone
                    for tz in map(pytz.timezone, pytz.all_timezones_set)
                    if cur_now.astimezone(tz).utcoffset() == cur_timeoffset
                ]
                if len(cur_offset_matches) > 1:
                    cur_firstchoice, cur_secondchoice = [], []
                    try:
                        print(f'Searching for {citi1}....')
                        cur_firstchoice += [
                            listitem for listitem in cur_offset_matches
                            if citi1 in listitem
                        ]
                    except:
                        pass
                    try:
                        print(f'Searching for {country1}....')
                        cur_firstchoice += [
                            listitem for listitem in cur_offset_matches
                            if country1 in listitem
                        ]
                    except:
                        pass
                    if len(cur_firstchoice) == 0:
                        try:
                            print(f'Searching for {cur_capital}....')
                            cur_firstchoice += [
                                listitem for listitem in cur_offset_matches
                                if cur_capital in listitem
                            ]
                        except:
                            pass
                    try:
                        print(f'Searching for {cur_countryname}....')
                        cur_firstchoice += [
                            listitem for listitem in cur_offset_matches
                            if cur_countryname in listitem
                        ]
                    except:
                        pass
                    if len(cur_firstchoice) >= 2:
                        try:
                            print(f'Searching for {citi1}....')
                            cur_secondchoice += [
                                listitem for listitem in cur_firstchoice
                                if citi1 in listitem
                            ]
                            if cur_secondchoice != '':
                                cur_firstchoice.insert(0, cur_secondchoice[0])
                            else:
                                print(f"City {citi1} not found.")
                            cur_secondchoice += [
                                listitem for listitem in cur_firstchoice
                                if cur_capital in listitem
                            ]
                            if cur_secondchoice != '':
                                cur_firstchoice.insert(0, cur_secondchoice[0])
                            else:
                                print(f"Capital city {cur_capital} not found.")
                        except:
                            pass
                    if len(cur_firstchoice) == 0:
                        cur_firstchoice = cur_offset_matches
                    print(f'Available timezones: {cur_firstchoice}.')
                    cur_zone = ''.join(cur_firstchoice[0])
                    print(f'Picked timezone: {cur_zone}.')
                else:
                    cur_zone = ''.join(cur_offset_matches)
                cur_zone = pytz.timezone(cur_zone)
                cur_sunrise = cur_sunrise.astimezone(cur_zone)
                cur_sunset = cur_sunset.astimezone(cur_zone)

                # Current Date
                cur_dt = cur_api['dt']

                # Current Date & Time converted from UNIX timestamp to UTC and then to Local
                cur_dt = datetime.datetime.fromtimestamp(cur_dt)
                cur_utc_dt = cur_dt.astimezone(utc)
                cur_dt = cur_utc_dt.astimezone(cur_zone)
                cur_date = cur_dt.strftime('%d %B, %Y')
                cur_time = cur_dt.strftime('%H:%M (%p)')

                # Update the information labels
                label_temp1.configure(
                    text=f"Temperature: {current_temperature1}" + '\u00b0')
                label_humidity1.configure(text=f"Humidity: {humidity1}%")
                max_temp1.configure(text="Max Temp Today: " + f"{tempmax1}" +
                                    '\u00b0')
                min_temp1.configure(text=f"Min Temp Today: {tempmin1}\u00b0")
                label_lon1.configure(text=f"Longitude: {longitude1}" +
                                     '\u00b0')
                label_lat1.configure(text=f"Latitude: {latitude1}" + '\u00b0')
                label_citi1.configure(text=f"{citi1}, {country1}")
                label_descrip1.configure(text=f"Weather: {descrip1}")
                label_time1.configure(text=f"Local Time: {cur_time}")
                label_date1.configure(text=f"{cur_date}")

                # Download and display the current weather icon
                try:
                    print(f"Trying to download icon from: {icon_url1}.")
                    r = requests.get(icon_url1, stream=True)
                    if r.status_code == 200:
                        r.raw.decode_content = True
                        with open(icon1, "wb") as f:
                            shutil.copyfileobj(r.raw, f)
                        print(f"Downloaded image: {icon1}.")
                        weatherapp.cur_image = ImageTk.PhotoImage(
                            Image.open(icon1))
                    else:
                        print(
                            f"Received HTTP status code {r.status_code} while trying to download {icon1}."
                        )
                        weatherapp.cur_image = ImageTk.PhotoImage(
                            Image.open(resource_path('img_notfound.jpeg')))
                except Exception as error:
                    print(f"Error occured with downloading {icon1}: {error}.")
                    weatherapp.cur_image = ImageTk.PhotoImage(
                        Image.open(resource_path('img_notfound.jpeg')))

                # Icon Placement
                label_icon1 = tkinter.Label(weatherapp,
                                            bg='white',
                                            image=weatherapp.cur_image)
                label_icon1.place(x=50, y=303)

                # Image application
                if cur_dt >= cur_sunrise:
                    if cur_dt <= cur_sunset:
                        print(f"In {self.cur_city} it is currently daytime.")
                        weatherapp.day_night1 = weatherapp.day
                    else:
                        print(f"In {self.cur_city} it is currently nighttime.")
                        weatherapp.day_night1 = weatherapp.night
                else:
                    print(f"In {self.cur_city} it is currently nighttime.")
                    weatherapp.day_night1 = weatherapp.night

                # Theme for the respective time the application is used
                weatherapp.cur_day_night_panel = tkinter.Label(
                    weatherapp, bg='white', image=weatherapp.day_night1)
                weatherapp.cur_day_night_panel.place(x=5, y=225)