Add slow typing and basic text inro

This commit is contained in:
2022-08-04 13:32:27 +02:00
parent c62df2bb21
commit de26838e1f
5 changed files with 43 additions and 0 deletions

19
src/utils/text.py Normal file
View File

@@ -0,0 +1,19 @@
"""
Utilities for text output
"""
import time
def type(text: str, delay: float = 0.05, newline_delay: float = 0.0) -> None:
""" Prints the given text, one character at a time, with a delay between each character.
Arguments:
text: The text to be printed.
delay: The delay between each character. (Default 0.05)
newline_delay: The delay between each newline. (Default 0.0)
"""
for char in text:
print(char, end="", flush=True)
if (char == "\n"):
time.sleep(newline_delay)
time.sleep(delay)