-
Notifications
You must be signed in to change notification settings - Fork 0
/
using-marquee.py
35 lines (28 loc) · 881 Bytes
/
using-marquee.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys
import time
def main():
program = animate()
program.data = "Hello World!!!" + " "
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()