Last active
July 12, 2023 08:44
-
-
Save secnnet/c9695b7a2a3e3953469ef3fd2cf5a049 to your computer and use it in GitHub Desktop.
Python script that displays a centered and enlarged animated positive message. The script uses colorama to apply green color to the message and utilizes ANSI escape sequences to create an animation effect by adding and removing underscores from each character. The animation repeats indefinitely until interrupted.
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 time | |
import shutil | |
import colorama | |
from colorama import Fore, Style | |
colorama.init() | |
message = "Hi, you are an awesome human being ☺" | |
def positive_message_animation(): | |
"""Display a centered and enlarged animated positive message that repeats until interrupted.""" | |
terminal_width = shutil.get_terminal_size().columns | |
padding = (terminal_width - len(message)) // 2 # Calculate padding for centering the message | |
while True: | |
# Animation loop to add underscore to each character | |
for i in range(len(message)): | |
animated_message = message[:i] + "_" + message[i+1:] # Add underscore to the current character | |
centered_message = " " * padding + Fore.GREEN + animated_message + Style.RESET_ALL # Apply formatting | |
print(f"\033[F\033[K{centered_message}", end="\r") # Move cursor up and clear line, print centered message | |
time.sleep(0.1) # Delay for animation effect | |
# Animation loop to remove underscore from each character | |
for i in range(len(message)): | |
animated_message = message[:i] + " " + message[i+1:] # Remove underscore from the current character | |
centered_message = " " * padding + Fore.GREEN + animated_message + Style.RESET_ALL # Apply formatting | |
print(f"\033[F\033[K{centered_message}", end="\r") # Move cursor up and clear line, print centered message | |
time.sleep(0.1) # Delay for animation effect | |
positive_message_animation() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment