Time.sleep() for ui?
Hello everybody, trying to create a simple timer that counts down from 10 to 0.
Creating one in that executes in console is no problem when using
time.sleepfunction and a simple while condition, but for the ui if using a
time.sleepfunction everything freezes. Read someware that
time.sleepdoes not work for the ui. Is that correct? And if so what should I use instead?
Hmm wrote it like this
import time, ui timme = 30 def CountDown(sender): global timme if timme > 0: label1.text = str(timme) ui.delay(sender.CountDown, 1) timme = timme - 1 label1.text = str(timme)
but now I get "Attribute error" ui.Button has no attribute 'CountDown' and it refering to the
line. Tried different combinations for the ui.delay but will always get this error. What am I missing?
In the line that is failing, sender is a ui.Button but you have defined CountDown as a standalone function, not as a method of ui.Button().
Try CountDown(sender) instead of sender.CountDown()
Also code format requires the three backticks are on a line by themselves with no other text before or after them on the same line.