I wish to write a program that will perform some action on a key press event but if there is no key press in a certain period of time say 10 seconds, it should display an error message and exit. I am working on windows and am using the Tkinter GUI. I have searched the net for a possible solution but though I have found a code which would display an error message on a mouse click event etc. I cannot understand how I can code the program to exit if no keys or mouse button is pressed.
Please could you give me some ideas as to how I should do this.
Thanks for your help
Jump to Post
Maybe you could create some kind of while loop who keeps checking if a user enters something and that breaks after 10 seconds and displays an error.
while current_time < error_time #error_time being your first time plus 10 seconds. if user_input : do_something else: current_time = time.ctime(time.time()) …
All 2 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.