I am making a GUI using kivy. It fetches 'static map image' (png) and 'Reverse geo-coded string'(json) from url. For that I am using kivy's builtin asynchronous urlrequest library. My program fetches (latitude, longitude) from a .csv file and shows the picture and address details on screen.Also some internal operations is performed based on the json data (dict)(for ex: how many words there are in address..). There is a ' next ' button, on pressed, next (lat,long) is picked and projected. Now I added an ' automate ' button which will iterate through the (lat,long) and call the exactly same functions when ' next ' is manually pressed, but upon executing, screen freezes, sometimes not responding, if somehow get executed the json data does not get time to refresh.
I am using time.sleep() . But it seems it is of no use. I have searched for it, I don't know whether it is because 'buffer'or not. Bellow is a part of the code:
def automate(self):
for i in range(5):)
self.next('NaN')
time.sleep(6)
You should use the Clock
object instead of time.sleep()
:
def automate(self):
Clock.schedule_interval(self.automate_next, 6)
def automate_next(self, dt):
self.next('NaN')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.