Reputation: 13
I've found a lot of similar questions to this, and maybe a more astute mind would have been able to figure this out through inference. Unfortunately I have very limited experience in Python, bear with me.
What I'm trying to do is create a Pomodoro timer, which in itself is very simple, but I can't seem to find out how to STOP the countdown before it runs the whole 25 minutes.
Essentially what I'm trying to do is keep documentation of my study time, and I don't want to include when I get up to use the restroom in that time so I'd like to be able to pause it and then resume the countdown of the remaining time right where it left off.
Like the title implies I'm using the time.sleep() function for the countdown, and the end goal is to apply start and pause to some buttons and a simple time display as a ui.
Upvotes: 0
Views: 700
Reputation: 5621
You can’t do this with time.sleep()
. However, you can use the output of time.time()
which gives you the number of seconds since Jan, 1st 1970, based on your computer’s clock. It’s then easy to store this value in variables when you start and stop the timer and to compare them to get the elapsed time.
Upvotes: 1