rich/examples/screen.py

22 lines
511 B
Python
Raw Normal View History

2021-02-12 21:59:35 +00:00
"""
Demonstration of Console.screen()
"""
from time import sleep
from rich.console import Console
from rich.align import Align
2021-02-14 09:48:34 +00:00
from rich.text import Text
2021-02-12 21:59:35 +00:00
from rich.panel import Panel
console = Console()
2021-02-14 09:48:34 +00:00
with console.screen(style="bold white on red") as screen:
for count in range(5, 0, -1):
text = Align.center(
Text.from_markup(f"[blink]Don't Panic![/blink]\n{count}", justify="center"),
vertical="middle",
)
screen.update(Panel(text))
sleep(1)