처음 영어 실력을 못 미안합니다.Kivy label.text에 출력 dict 값
API에 대해 배우고 있으며 매우 기본적인 KIVY 인터페이스에 날씨 API를 구현하기로 결정했습니다. 그러나 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