Skip to content

Instantly share code, notes, and snippets.

@meatyite
Created March 9, 2019 15:30
Show Gist options
  • Save meatyite/89ce18ade5e18ba7ea425ddc75053ae5 to your computer and use it in GitHub Desktop.
Save meatyite/89ce18ade5e18ba7ea425ddc75053ae5 to your computer and use it in GitHub Desktop.
pyTypingCinema | Typewriter effect in python
#!/usr/bin/python3
import os, sys
from time import sleep
filename = ""
wait_before_each_char = 0.05
def cls():
os.system('cls' if os.name=='nt' else 'clear')
def main():
file_chars = open(filename, 'r').read()
cls()
file_string = ""
for file_char in file_chars:
file_string += file_char
print(file_string)
sleep(wait_before_each_char)
cls()
if __name__ == "__main__":
for arg_num in range(1, len(sys.argv)):
arg = sys.argv[arg_num]
if arg == '-w':
wait_before_each_char = float(sys.argv[arg_num + 1])
elif arg == '-f':
filename = sys.argv[arg_num + 1]
elif arg == '-h' or arg == '--help':
print("""\
usage: pyTypingCinema [flag1] [flag1 arg]
-h show this help menu and quit
-w [time] how much time (in seconds) to wait before each char, decimals are also allowed
-f [file] file to read from
""")
sys.exit(0)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment