0

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

7th Aug 2020, 11:07 PM
Owen Singh
Owen Singh - avatar
5 Answers
0
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.
7th Aug 2020, 11:16 PM
Slick
Slick - avatar
0
Slick I want to do it with onkeypress not on button press, grid forget for tkinter?
7th Aug 2020, 11:19 PM
Owen Singh
Owen Singh - avatar
0
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
7th Aug 2020, 11:22 PM
Slick
Slick - avatar
0
Slick i don't want button i want on key press like Capslock or something
7th Aug 2020, 11:43 PM
Owen Singh
Owen Singh - avatar
0
okay, then map to a keypress. its basically the same https://effbot.org/tkinterbook/tkinter-events-and-bindings.htm
7th Aug 2020, 11:47 PM
Slick
Slick - avatar