|
| 1 | +from tkinter import * |
| 2 | + |
| 3 | +t = 0 |
| 4 | + |
| 5 | + |
| 6 | +def set(): |
| 7 | + global t |
| 8 | + t = t + int(entry.get()) |
| 9 | + return t |
| 10 | + |
| 11 | + |
| 12 | +def start(): |
| 13 | + global t |
| 14 | + if t > 0: |
| 15 | + lbl.config(text=t) |
| 16 | + t = t - 1 |
| 17 | + lbl.after(1000,start) |
| 18 | + return t |
| 19 | + elif t == 0: |
| 20 | + lbl.config(text="go") |
| 21 | + |
| 22 | + |
| 23 | +root = Tk() |
| 24 | + |
| 25 | +root.geometry("380x350") |
| 26 | +root.config(bg="black") |
| 27 | + |
| 28 | +Label(root, text="Count Down Timer", font=("bell mt", 30),bg="black",fg="#00ff00").grid(row=0, column=0, padx=20) |
| 29 | + |
| 30 | +Label(root,text="Select the seconds",font=("bell mt",20),bg="black",fg="#00ff00").grid(row=1,column=0,padx=20) |
| 31 | + |
| 32 | +entry = Entry(root, font=("castellar", 15),fg="black") |
| 33 | +entry.grid(row=2, column=0, padx=20,pady=15) |
| 34 | + |
| 35 | +b1 = Button(root, text='Set Timer', font=("bell mt", 20),bg="black",fg="#00ff00",width=10,height=1, command=set) |
| 36 | +b1.grid(row=3, column=0, padx=20,pady=10) |
| 37 | + |
| 38 | +b2 = Button(root, text='Start Timer', font=("bell mt", 20),bg="black",fg="#00ff00",width=10,height=1, command=start) |
| 39 | +b2.grid(row=4, column=0, padx=20,pady=10) |
| 40 | + |
| 41 | +lbl = Label(root, text="", font=("algerian", 30),fg="#00ff00",bg="black") |
| 42 | +lbl.grid(row=5, column=0, padx=20) |
| 43 | + |
| 44 | +root.mainloop() |
0 commit comments