'Python Kivy: Label text will not be diesplayed: synchrounous or asynchronous processing?

With this code:

statusLbl = Label(text="")


def btn_callback(instance):
    statusLbl.text = "you never see this message: Start to work"
    print("but you would see ths in the console: Start to work")
    thisTakesSomeTime(instance)
    statusLbl.text = "finished work (you will see this)" 
    print("and you will see this: finished")      
    
class myAPP(App):
  def build(self):
    layout = BoxLayout(orientation='vertical')
    btn = Button(text="start this long process as often as you want to!!") 
    layout.add_widget(btn)
    layout.add_widget(statusLbl)
    return layout
    

myApp = myAPP()
myApp.run()    

there are some problems:

(1) the statusLabel will not be refreshed before calling "thisTakesSomeTime(instance)" (2) it seems to be possible to call the callback many times, each time before the execution of thisTakesSomeTime is finished. This is not a problem as such, but in combination with (1) without refreshing I would have to stop any call to thisTakesSomeTime(..) until each call is finished, because the user would tend to think, he did not push the button and try again (and again). Multiple executions would be o.k. if the user intends to do so (which he only can decide, if he knows, that the execution already begun).

So the most simple question is: is there a way to force a refresh/redraw of statusLbl before calling thisTakesSomeTime?

Otherwise: could any multithreading attempt help? (I don't have much experience with this in python and no experience with this in kivy and on android). So (if there is no simple answer to the redraw problem): what would be the proper way to come to structured processing?

Thank you!



Solution 1:[1]

Kivy uses the main thread to update your GUI, but it cannot do so if you hold the main thread with a thisTakesSomeTime() method. Yes, using threading will fix it. See the documentation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Anderson