私の悪い英語の最初の申し訳ありません。Kivy label.textの出力dict値
私はAPIについて学習しており、天気APIを非常に基本的なKIVYインターフェイスに実装することに決めました。しかし、Imは天気に関する情報を含むDictの出力値をラベルテキストとして得ることができません。私は値が文字列ではないと思う。あなたは私を助けてくれますか?
class Tempo_Func(BoxLayout):
def tempo(self,cidade):
req=requests.get('http://api.openweathermap.org/data/2.5/weather?q='
+cidade+ '&appid=mykey')
self.tempo = json.loads(req.text)
self.x =(self.tempo['weather'][0]['main'])
class WeatherApp(App):
def build(self):
return Tempo_Func()
if __name__=='__main__':
WeatherApp().run()
KV
<Tempo_Func>:
orientation:'vertical'
padding:10
spacing:10
BoxLayout:
orientation:'vertical'
Label:
text:"Qual sua cidade?"
size_hint_y:None
TextInput:
id:entry
Button:
text:'Procurar'
on_press:root.tempo(entry.text)
Label:
text:root.x #I want to show the value of self.x here!!
トレースバックとは何ですか? – Kanak