Created
August 14, 2024 19:37
-
-
Save idcesares/8891a635cc242014bcd0dfe4ce4abd65 to your computer and use it in GitHub Desktop.
Fancy Hello World in Python the using Rich Library
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
# Install the Rich library: ```pip install rich``` | |
from rich.console import Console | |
from rich.text import Text | |
from time import sleep | |
console = Console() | |
# Create a Text object for the animated text | |
animated_text = Text("", style="bold") | |
# The message to display | |
message = "Hello, World!" | |
# Animate the message letter by letter | |
for i, char in enumerate(message): | |
animated_text.append(char, style=f"bold {['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'][i % 6]}") | |
console.print(animated_text, justify="center") | |
sleep(0.2) # Adjust the sleep time to speed up or slow down the animation | |
# Print a fancy border after the animation | |
console.print("-" * 25, justify="center") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment