Tkinter countdown overlay help
Hello I am trying to make a simple script which on key press x starts a timer of 45 sec after that when it reaches 10 sec color text changes to red and when countdown comes 0 I want to destroy the timer gui but not the program, and when i press x again program starts doing stuff again and repeats the process So far I managed this I tried all day I also tried adding on keypress but it become so complicated and didn't worked so I am asking help here https://code.sololearn.com/cDAUETkgYcHI/?ref=app
8/7/2020 11:07:44 PMOwen Singh
5 AnswersNew Answer
try grid_forget() or pack_forget() to hide the timer have a method that places a number, waits a second, deletes the number and then places the next number in the timer until 0. link it to the button. use an if else statement to change the color once it hits a certain number.
Slick I want to do it with onkeypress not on button press, grid forget for tkinter?
just map the function to a button then. and yes, if you placed the (I assume you used a) label widget with pack use pack_forget if placed with grid, use grid forget and the widget will dissapear. it can be called back. just do some reasearch on the forget methods
Slick i don't want button i want on key press like Capslock or something
okay, then map to a keypress. its basically the same https://effbot.org/tkinterbook/tkinter-events-and-bindings.htm