这是我的课:
class Myapp():
def __init__(self, *args, **kwargs):
super(Myapp, self).__init__(*args, **kwargs)
self.update_bar_trigger = Clock.create_trigger(self.MyFunction)
def MyFunction() :
#some code here
for folder in range(len(list_folders)):
#some code here
list_files = os.listdir(folder)
for file in list_files : # list_file is a list
# here i read about 20 excel files that exist in the folder
# i do some data processing here
print("done")
for dictionary in list_dictionary :
# here i manipulate lot of dictionaries
print("done")
当我有一个循环时,我遇到了同样的问题,我问这里的人,他们建议我使用Clock.create_trigger
。对我来说效果很好。这是一个示例:
def __init__(self, *args, **kwargs):
super(Myapp, self).__init__(*args, **kwargs)
self.update_bar_trigger = Clock.create_trigger(self.update_bar)
def clicked(self):
self.i = 0
self.update_bar_trigger()
def update_bar(self, dt):
if self.i <= 10000: # for me, here it was "for i in range(10001):"
self.ids.pb.value += self.i
self.i += 1
self.update_bar_trigger()
当我们有很多循环时,是否有解决方案/方法可以做同样的事情?
非常感谢