
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("350x170") # width and height of the window
counter=11 # Initital value of counter
def my_time():
global counter
counter=counter-1 # decrease value by 1
if counter < 0:
return
l1.config(text=str(counter)) # Update the label text using string
l1.after(1000,my_time) # time delay of 1000 milliseconds
my_font=('times',76,'bold') # display size and style
l1=tk.Label(my_w,font=my_font,bg='yellow',width=2)
l1.grid(row=1,column=1,padx=50,pady=30)
my_time() # call the function
my_w.mainloop()

def restart():
global counter
counter=11 # start value
my_time() # call the function
b1=tk.Button(my_w,text='Restart',font=22,command=lambda:restart())
b1.grid(row=1,column=2,padx=10)

Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.