Is there a way to restrict user to input something in the console while time.sleep
is running?
I tried this code and its working but i wondered if there is another way to do this:
import threading
import os
import time
import sys
print("Wait a moment")
def clearer():
c = 0
d = 5000
while d != c:
print(" ", end="")
time.sleep(0.001)
print("\r = ", end="")
c += 1
a = threading.Thread(target=clearer, args=())
a.start()
a.join()
os.system('clear')
print("Good Job")
sys.exit()
Another Way
Yeah I find another way...
It's by using curses modules
import time
import curses
import os
screen = curses.initscr()
def stop(curse):
curses.curs_set(0)
print("Wait a moment...")
time.sleep(2)
curses.flushinp()
curses.wrapper(stop)
os.system('clear')
curses.curs_set(1)
print("Thanks you for waiting")
a = input("Type something: ")
curses.wrapper(stop)
os.system('clear')
print(a)
--- Using pydroid3 on android