Add slow typing and basic text inro
This commit is contained in:
19
src/utils/text.py
Normal file
19
src/utils/text.py
Normal 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)
|
||||
Reference in New Issue
Block a user