Created
June 24, 2016 03:12
-
-
Save the-c0d3r/eceef8a5a0eaf0f86ec09c0451efac8f to your computer and use it in GitHub Desktop.
A marquee effect of HTML with python inside terminal
This file contains hidden or 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 | |
def main(): | |
program = animate() | |
program.data = input("Enter string : ") + " " | |
program.width = int(input("Enter width : ")) | |
program.animate() | |
class animate: | |
def __init__(self): | |
self.data = "" | |
self.width = 0 | |
def animate(self): | |
try: | |
while True: | |
for x in range(0, self.width): | |
time.sleep(0.1) | |
msg = "\r{}{}".format(" " * x, self.data) | |
sys.stdout.write(msg) | |
sys.stdout.flush() | |
for x in range(self.width, 0, -1): | |
time.sleep(0.1) | |
msg = "\r{}{}".format(" " * x, self.data) | |
sys.stdout.write(msg) | |
sys.stdout.flush() | |
except KeyboardInterrupt: | |
print("Exiting") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo