project/__main__.py
def search_function(self):
        """
        Called with someone presses the
        `enter`-button. Basically does everything:
        - Fetches the search field
        - Decides whether it should use the real word or swap it out
        - Fetches backend for weather information
        - Display information
        - Calls on the change_background() function
        - Display the location it actually searched for in the search bar
        """
        # Get the search string
        search_string = self.search_bar.get()

        # 50% of getting the wrong intended location:
        if random.choice([True, False]):
            location = get_similar_location(search_string)
        else:
            location = search_string

        # Show where we actually searched to the end user
        self.show_location_name(location)

        # Fetch the weather for the next 7 days:
        weather = ForecastFetcher("OWM_API_KEY")
        weather = weather.fetch_forecast_7_days(location, "random")

        # We put todays weather tomorrow, and tomorrows weather today
        today = weather[1]
        tomorrow = weather[0]
        todays_weather = today['weather_status']

        # Change content for the content boxes
        self.todays_content.config(
            text=f"Day temperature: {today['day temperature']}\n"
            f" Evening temperature: {today['evening temperature']}\n"
            f" High: {today['highest temperature']}, "
            f"Low: {today['lowest temperature']}"
        )
        self.tomorrows_content.config(
            text=f"Day temperature: {tomorrow['day temperature']}\n"
            f" Evening temperature: {tomorrow['evening temperature']}\n"
            f" High: {tomorrow['highest temperature']}, "
            f"Low: {tomorrow['lowest temperature']}"
        )

        # Also change the background:
        self.change_background(todays_weather)

        Called with someone presses the
        `enter`-button. Basically does everything:
        - Fetches the search field
        - Decides whether it should use the real word or swap it out
        - Fetches backend for weather information
        - Display information
        - Calls on the change_background() function
        - Display the location it actually searched for in the search bar
        
Called with someone presses the
`enter`-button. Basically does everything:
Fetches the search field
Decides whether it should use the real word or swap it out
Fetches backend for weather information
Display information
Calls on the change_background() function
Display the location it actually searched for in the search bar
Called with someone presses the ` enter ` - button . Basically does everything : Fetches the search field Decides whether it should use the real word or swap it out Fetches backend for weather information Display information Calls on the change_background () function Display the location it actually searched for in the search bar
def search_function(self):
        search_string = self.search_bar.get()
        if random.choice([True, False]):
            location = get_similar_location(search_string)
        else:
            location = search_string
        self.show_location_name(location)
        weather = ForecastFetcher("OWM_API_KEY")
        weather = weather.fetch_forecast_7_days(location, "random")
        today = weather[1]
        tomorrow = weather[0]
        todays_weather = today['weather_status']
        self.todays_content.config(
            text=f"Day temperature: {today['day temperature']}\n"
            f" Evening temperature: {today['evening temperature']}\n"
            f" High: {today['highest temperature']}, "
            f"Low: {today['lowest temperature']}"
        )
        self.tomorrows_content.config(
            text=f"Day temperature: {tomorrow['day temperature']}\n"
            f" Evening temperature: {tomorrow['evening temperature']}\n"
            f" High: {tomorrow['highest temperature']}, "
            f"Low: {tomorrow['lowest temperature']}"
        )
        self.change_background(todays_weather)
def search_function ( self ) : search_string = self . search_bar . get ( ) if random . choice ( [ True , False ] ) : location = get_similar_location ( search_string ) else : location = search_string self . show_location_name ( location ) weather = ForecastFetcher ( "OWM_API_KEY" ) weather = weather . fetch_forecast_7_days ( location , "random" ) today = weather [ 1 ] tomorrow = weather [ 0 ] todays_weather = today [ 'weather_status' ] self . todays_content . config ( text = f"Day temperature: {today['day temperature']}\n" f" Evening temperature: {today['evening temperature']}\n" f" High: {today['highest temperature']}, " f"Low: {today['lowest temperature']}" ) self . tomorrows_content . config ( text = f"Day temperature: {tomorrow['day temperature']}\n" f" Evening temperature: {tomorrow['evening temperature']}\n" f" High: {tomorrow['highest temperature']}, " f"Low: {tomorrow['lowest temperature']}" ) self . change_background ( todays_weather )
Called with someone presses the
`enter`-button.
Called with someone presses the ` enter ` - button .
"""
        Called with someone presses the
        `enter`-button. Basically does everything:
        - Fetches the search field
        - Decides whether it should use the real word or swap it out
        - Fetches backend for weather information
        - Display information
        - Calls on the change_background() function
        - Display the location it actually searched for in the search bar
        """ # Get the search string # 50% of getting the wrong intended location: # Show where we actually searched to the end user # Fetch the weather for the next 7 days: # We put todays weather tomorrow, and tomorrows weather today # Change content for the content boxes # Also change the background:
self