Server IP : 85.214.239.14 / Your IP : 3.16.49.213 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/proc/2/cwd/proc/self/root/usr/share/doc/python3-rich/examples/ |
Upload File : |
""" Demonstrates a dynamic Layout """ from datetime import datetime from time import sleep from rich.align import Align from rich.console import Console from rich.layout import Layout from rich.live import Live from rich.text import Text console = Console() layout = Layout() layout.split( Layout(name="header", size=1), Layout(ratio=1, name="main"), Layout(size=10, name="footer"), ) layout["main"].split_row(Layout(name="side"), Layout(name="body", ratio=2)) layout["side"].split(Layout(), Layout()) layout["body"].update( Align.center( Text( """This is a demonstration of rich.Layout\n\nHit Ctrl+C to exit""", justify="center", ), vertical="middle", ) ) class Clock: """Renders the time in the center of the screen.""" def __rich__(self) -> Text: return Text(datetime.now().ctime(), style="bold magenta", justify="center") layout["header"].update(Clock()) with Live(layout, screen=True, redirect_stderr=False) as live: try: while True: sleep(1) except KeyboardInterrupt: pass