def update_temp(): global temp1 global temp_ knowledge = Knowledge() weather_json = knowledge.weather_knowledge() location_json = knowledge.location_knowledge() temp_ = weather_json['main']['temp'] location_temp = location_json['state_prov'] if temp1 != temp_: temp1 = temp_ text = int(temp1 - 273) temp.config(text=location_temp + "City\n%d oC" % text) temp.after(50000, update_greeting)