Last active
April 22, 2020 19:33
-
-
Save AlephNotation/7c95c25a6f859d95410be3ba5690f835 to your computer and use it in GitHub Desktop.
Flash stdout centered to terminal width for extra oomph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import shutil | |
def blink_once(input, empty_str, wait=0.05): | |
sys.stdout.write(f'\r{input}') | |
time.sleep(wait) | |
sys.stdout.write(f'\r{empty_str}') | |
time.sleep(wait) | |
def blink(number, text): | |
rows, columns = shutil.get_terminal_size((80, 20)) | |
text = text.center(rows, "_") | |
empty_space = " " * rows | |
for x in range(0,number): | |
blink_once(text, empty_space) | |
while True: | |
blink(10, "Verbum caro factum est") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment