From 4ad4e4b3a4a91c84ec63f03662d6a9fa6291cfcc Mon Sep 17 00:00:00 2001 From: Felix Pan Date: Wed, 1 Jul 2020 17:12:56 +0800 Subject: [PATCH] Use icons in kivy --- module_kivy/kivy_weather_app/main.py | 2 ++ module_kivy/kivy_weather_app/weather.kv | 2 ++ 2 files changed, 4 insertions(+) diff --git a/module_kivy/kivy_weather_app/main.py b/module_kivy/kivy_weather_app/main.py index 0623e671..3663ecbb 100644 --- a/module_kivy/kivy_weather_app/main.py +++ b/module_kivy/kivy_weather_app/main.py @@ -35,6 +35,7 @@ def show_add_location_form(self): class CurrentWeather(BoxLayout): location = ListProperty(['New York', 'US']) conditions = StringProperty() + conditions_image = StringProperty() temp = NumericProperty() temp_min = NumericProperty() temp_max = NumericProperty() @@ -49,6 +50,7 @@ def weather_retrieved(self, request, data): self.temp = data['main']['temp'] self.temp_min = data['main']['temp_min'] self.temp_max = data['main']['temp_max'] + self.conditions_image = 'http://openweathermap.org/img/w/{}.png'.format(data['weather'][0]['icon']) class AddLocationForm(BoxLayout): diff --git a/module_kivy/kivy_weather_app/weather.kv b/module_kivy/kivy_weather_app/weather.kv index ffa7052b..0fb23061 100644 --- a/module_kivy/kivy_weather_app/weather.kv +++ b/module_kivy/kivy_weather_app/weather.kv @@ -12,6 +12,8 @@ WeatherRoot: font_size: '30dp' Label: text: root.conditions + AsyncImage: + source: root.conditions_image BoxLayout: orientation: 'horizontal' Label: