im traying to do a progress bar in kivy, i can build the app with it but it can't be udpated when i run a function (loop) how can i do this please ?
here is my code : import libraries :
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.properties import ObjectProperty
from kivy.core.window import Window
from kivy.clock import Clock
from kivy.logger import Logger
from kivy.uix.progressbar import ProgressBar
My builder :
Builder.load_string("""
<RootWidget>:
pb : pb
some code here
ActionView:
ActionPrevious:
with_previous: False
ActionButton:
text: 'Run analysis'
color: 29/255, 185/255, 84/255, 1
on_release: root.clicked()
BoxLayout:
ProgressBar:
id : pb
min :0
max :1
pos_hint: {'x': .1}
size_hint_x :.8
size_hint_y :.5
value: 0
""")
other code with my update_bar function:
class Myapp(BoxLayout):
pb = ProgressBar()
box = ObjectProperty()
def __init__(self, *args, **kwargs):
super(Myapp, self).__init__(*args, **kwargs)
def update_bar(self,dt=None):
self.ids.pb.value = self.ids.pb.value
here is the problem : the progress bar is not updated each iteration, but it take the last value (for i = 9999)
def clicked(self):
for i in range(10000) :
self.ids.pb.value = i/10000
Clock.schedule_interval(self.update_bar,0.5)
self.update_bar()
Build my app :
class EventScreen(App,Myapp):
def on_stop(self):
Logger.critical("Good bye")
def build(self):
return Myapp()
if __name__ == "__main__":
EventScreen().run()
thank you in advance