Прозрачность у Image kivy
Только начал изучать kivy и решил сделать приложение погоды. Одна из функций ниже берёт данные с сайта погоды, и одним из возвращаемых значений является иконка погоды. Проблема заключается в том, что мне нужно, чтобы при создании приложения, иконка погоды была прозрачная, а она показывается как просто белый квадрат. Я попытался установить opacity, но всё бесполезно. Если кто-то подскажет, в чём проблема буду очень благодарен! Вот мой код:
main.py:
from kivy.app import App
from kivy.core.window import Window
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from statics import function
class MainContainer(BoxLayout):
search = ObjectProperty()
cityName = ObjectProperty()
weatherIcon = ObjectProperty()
temp = ObjectProperty()
feelTemp = ObjectProperty()
weatherDescription = ObjectProperty()
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.weatherIcon.opacity = 1.0
def setWeather(self):
weather = function.find(self.cityName.text)
print(weather)
self.weatherIcon.source = weather['icon_source']
self.temp.text = weather['temp_real']
self.feelTemp.text = weather['temp_feels']
self.weatherDescription.text = weather['description']
class WeatherApp(App):
def build(self):
Window.clearcolor = (0.8, 0.8, 0.8, 1)
Window.size = (700, 350)
return MainContainer()
if __name__ == '__main__':
WeatherApp().run()
function.py:
import requests
def find(city):
callback = dict()
key = '110e6871bbbfd9e712471e94efb92953'
res = requests.get("http://api.openweathermap.org/data/2.5/weather",
params={'q': city, 'type': 'like', 'units': 'metric', 'lang': 'ru', 'APPID': key}).json()
if res['cod'] == '404' or 'weather' not in res.keys():
return callback
icon_id = res['weather'][0]['icon']
callback['icon_source'] = f'http://openweathermap.org/img/wn/{icon_id}@2x.png'
callback['temp_real'] = str(int(res['main']['temp'])) + '°C'
callback['temp_feels'] = str(int(res['main']['feels_like'])) + '°C'
callback['description'] = str(res['weather'][0]['description'])
return callback
weather.kv:
<MainContainer@BoxLayout>:
cityName:cityName
weatherIcon: weatherIcon
temp:temp
feelTemp: feelTemp
weatherDescription: weatherDescription
orientation: 'vertical'
BoxLayout:
canvas.before :
Rectangle:
pos : self.pos
size : self.size
source : 'clouds.jpg'
BoxLayout:
size_hint: 0.006, 0.09
BoxLayout:
size_hint: 0.03, 0.9
pos_hint: {'center_y': 0.5}
TextInput:
id: cityName
text: ''
size_hint: 0.5, 0.09
pos_hint: {'center_y': 0.9}
font_size: 12
BoxLayout:
size_hint: 0.001, 0.5
pos_hint: {'center_y': 1.065}
BoxLayout:
size_hint: 0.007, 0.5
pos_hint: {'center_y': 1.065}
Button:
search:search
id:search
on_press: root.setWeather()
size_hint: 0.007, 0.17
text: 'Поиск'
BoxLayout:
size_hint: 0.001, 0.09
BoxLayout:
orientation:'vertical'
size_hint: 0.007, 0.17
BoxLayout:
pos_hint: {'center_x': -4.9}
size_hint: 1.3, 2.5
AsyncImage:
id:weatherIcon
pos_hint: {'top': 4}
size_hint: 1.7, 2.7
BoxLayout:
orientation:'vertical'
size_hint: 0.007, 0.45
pos_hint: {'top': 0.679}
GridLayout:
pos_hint: {'center_x': -3.9}
size_hint: 1.7, 0.8
cols: 1
rows: 3
Label:
id: temp
size_hint: 1.7, 0.5
font_size: 30
color: 'black'
Label:
size_hint: 1.7, 0.2
Label:
id:feelTemp
size_hint: 1.7, 0.5
font_size: 30
color: 'black'
BoxLayout:
orientation:'vertical'
size_hint: 0.007, 0.17
BoxLayout:
pos_hint: {'center_x': -2.7}
size_hint: 1.3, 2.5
Label:
id:weatherDescription
pos_hint: {'top': 4}
size_hint: 1.7, 2.7
color: 'white'
font_size: 20