Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
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 usingtime.sleep
function and a simple while condition, but for the ui if using atime.sleep
function everything freezes. Read someware thattime.sleep
does not work for the ui. Is that correct? And if so what should I use instead? -
-
@ccc thx!
-
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
ui.delay(sender.CountDown, 1)
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.
-
This post is deleted! -
This post is deleted!