0

hey i am making a program which records desktop screen.

So what i want to do is when ever i click on my start button(tkinter Gui) in my gui window.

It should start a timer like 3.... ,2.... ,1.... in big font directly on my desktop screen and not on my tkinter window. and then my function should start.

How can i do that ..

import tkinter as tk from tkinter import * root = Tk() root.title("our program") start_cap =tk.button(text='start recording' command=start_capute) start_cap.pack() root.mainloop() 

Not mentioning the functions and the entire code here as not necessary the code is working fine and i just want to add a new feature of the timer in it.

1
  • There are dozens of questions on this site related to timers and clocks. Have you done any research before asking the question? Commented Mar 14, 2020 at 14:32

1 Answer 1

2

An minimal example:

import tkinter as tk # from tkinter import * def Start(): def Count(Number): if Number == -1: win.withdraw() print("Start") # what you want to do return False NumberLabel["text"] = Number win.after(1000,Count,Number-1) screen_width = root.winfo_screenwidth() screen_height = root.winfo_screenheight() win = tk.Toplevel() win.geometry("+%d+%d"%((screen_width-win.winfo_width())/2,(screen_height-win.winfo_height())/2)) # make it in the center. win.overrideredirect(1) win.wm_attributes('-topmost',1) # top window win.wm_attributes('-transparentcolor',win['bg']) # background transparent. NumberLabel = tk.Label(win,font=("",40,"bold"),fg='white') NumberLabel.pack() win.after(0,lambda :Count(3)) win.mainloop() root = tk.Tk() root.title("our program") start_cap = tk.Button(text='start recording',command=Start) start_cap.pack() root.mainloop() 
Sign up to request clarification or add additional context in comments.

2 Comments

No need to use global Number. Pass it as an argument to Count().
Use win.after(1000, Count, Number-1) instead of lambda and Number -= 1.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.