Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_timer.py
- try:
- # Python2
- import Tkinter as tk
- except ImportError:
- # Python3
- import tkinter as tk
- import time
- minutes=60
- def count_down():
- for t in range(minutes*2, -1, -1):
- sf = "{:02d}:{:02d}".format(*divmod(t, 60))
- time_str.set(sf)
- try:
- root.update()
- except:
- return
- time.sleep(1)
- root = tk.Tk()
- time_str = tk.StringVar()
- label_font = ('helvetica', 40)
- tk.Label(root, textvariable=time_str, font=label_font, bg='white',
- fg='blue', relief='raised', bd=3).pack(fill='x', padx=5, pady=5)
- time_str.set('00:00')
- root.update()
- tk.Button(root, text='Count Start', command=count_down).pack()
- tk.Button(root, text='Count Stop', command=root.destroy).pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement