1counter = 1
2print(counter)
3import time
4while True:
5 time.sleep(60)
6 counter += 1
7 print(counter)
8#this adds one to the counter every 60 seconds
1# import the time module
2import time
3
4# define the countdown func.
5def countdown(t):
6
7 while t:
8 mins, secs = divmod(t, 60)
9 timer = '{:02d}:{:02d}'.format(mins, secs)
10 print(timer, end="\r")
11 time.sleep(1)
12 t -= 1
13
14 print('Fire in the hole!!')
15
16
17# put time in seconds here
18t = 10
19
20# function call
21countdown(int(t))
22
1import tkinter as tk
2
3
4class ExampleApp(tk.Tk):
5 def __init__(self):
6 tk.Tk.__init__(self)
7 self.label = tk.Label(self, text="", width=10)
8 self.label.pack()
9 self.remaining = 0
10 self.countdown(10)
11
12 def countdown(self, remaining = None):
13 if remaining is not None:
14 self.remaining = remaining
15
16 if self.remaining <= 0:
17 self.label.configure(text="time's up!")
18 else:
19 self.label.configure(text="%d" % self.remaining)
20 self.remaining = self.remaining - 1
21 self.after(1000, self.countdown)
22
23if __name__ == "__main__":
24 app = ExampleApp()
25 app.mainloop()