0

I have built a game, and I am trying to display a countdown timer display to let the player know how much time he/she has to make a move.

def countdown(sec):
     while sec:
     minn, secc = divmod(sec, 60)
     timeformat = '{:02d}:{:02d}'.format(minn, secc)
     self.messages['text'] = timeformat
     t.sleep(1)
    sec -= 1


countdown(15)

The issue i run into is that this code freeze my application, where the user is unable to play until the countdown finishes. So I am trying to see how I could rewrite this code so that it does not affect the application. I think sleeps puts the game to sleep.

I have used Tkinter to build the interface of my app, and so the timer would need to be displayed on screen.

Thanks in advance.

Johny
  • 13
  • 2
  • Does this answer your question? [Making a countdown timer with Python and Tkinter?](https://stackoverflow.com/questions/10596988/making-a-countdown-timer-with-python-and-tkinter) – Ronald Jul 26 '20 at 21:41
  • There are many questions on this site related to creating clocks and timers and alarms. Have you searched for an answer? – Bryan Oakley Jul 26 '20 at 21:49
  • 1
    Does this answer your question? [How to create a timer using tkinter?](https://stackoverflow.com/questions/2400262/how-to-create-a-timer-using-tkinter) – jasonharper Jul 26 '20 at 21:50
  • I recently answered a question facing similar issue as you and [explained](https://stackoverflow.com/a/62985443/5722359) how you can do this using tkinter. – Sun Bear Jul 26 '20 at 22:21

0 Answers0