Хотел сделать погодник. Есть 2 поля: поле ввода и поле информации. После того, как я ввел название города, а инфа в другом поле не обновилась
#import modules
import kivy
import pyowm
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import Button as btn
from kivy.uix.label import Label as label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput as input
from pyowm import OWM
#WeatherAPI token
owm = OWM("")#token
class WeatherApp(App):
def __init__(self):
super().__init__()
self.weather_info = label(text = "Location: -\n\nTemperature: \nWeather: ")
#user input (awesome city) name and app shows t° and weather status
self.city = input(on_text=self.on_text, multiline = False)
self.city.bind(on_text=self.on_text)
def on_text(self, *args):
data = self.city.text
manager = owm.weather_manager()
place = manager.weather_at_place(data)
w = place.weather
t = w.temperature("celsius")
temp = t['temp']
status = w.detailed_status
self.weather_info.text = f'Location: {data}\n\nTemperature: {round(temp)}°C\nWeather: {status}'
def build(self):
box = BoxLayout(orientation="vertical")
#pole, where user input (awesome sity) name
box.add_widget(self.city)
#pole, where add weather_info
box.add_widget(self.weather_info)
#shows all of the above
return box
if __name__ == '__main__':
WeatherApp().run()
Если что, токен у меня есть и я его вставил в код
