Skip to content

Instantly share code, notes, and snippets.

@the-c0d3r
Created June 24, 2016 03:12
Show Gist options
  • Save the-c0d3r/eceef8a5a0eaf0f86ec09c0451efac8f to your computer and use it in GitHub Desktop.
Save the-c0d3r/eceef8a5a0eaf0f86ec09c0451efac8f to your computer and use it in GitHub Desktop.
A marquee effect of HTML with python inside terminal
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()
@the-c0d3r
Copy link
Author

Demo

@aliquazi1009
Copy link

Really Awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment