Tkinter function print in GUI

前端 未结 2 1773
野性不改
野性不改 2021-01-22 16:49

I have done a program with 2 apis that show forecast and city info of diffrent citys that the user choose. But now I need help cause Im stuck on how to get my make_request, make

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-22 17:22

    Example - I use existing label with title to set information from request

    def make_request(self):
        r = requests.get("http://api.wunderground.com/api/61418d709872f773/forecast/q/" + self.enterCountry.get() +"/" + self.v.get() +".json")
        data = r.json()
        for day in data['forecast']['simpleforecast']['forecastday']:
            self.var.set( day['date']['weekday'] + ":" + "\n" + "Conditions: " + day['conditions'] + "\n" + "High: " + day['high']['celsius'] + "C " + "Low: " + day['low']['celsius'] + "C" )
        return data
    

提交回复
热议问题