def changeBackground(sender):
z=sender.superview
x=1
while x<=10:
button='button'+str(x)
z[button].background_color=(0,0,0)
x+=1
time.sleep(1)
In my mind, this code (assuming that this gets called by pressing a button) should change the background color of 'button1', 'button2', and so on in order. Changing one every second.
However, if this code was ran the program would wait for 10 seconds and then update all of the buttons' background colors at once. How can I get it to update the UI at the time when that line of code is ran? I have tried z[button].set_needs_display() to no avail.
Thanks!