ignore overflow in columns example

This commit is contained in:
Will McGugan 2020-08-12 21:34:24 +01:00
parent 8e94315c3b
commit eadc162feb
1 changed files with 5 additions and 3 deletions

View File

@ -7,7 +7,7 @@ The data is pulled from https://randomuser.me
import json
from urllib.request import urlopen
from rich import print
from rich.console import Console
from rich.columns import Columns
from rich.panel import Panel
@ -18,8 +18,10 @@ def get_content(user):
name = f"{user['name']['first']} {user['name']['last']}"
return f"[b]{name}[/b]\n[yellow]{country}"
console = Console()
users = json.loads(urlopen("https://randomuser.me/api/?results=30").read())["results"]
print(users)
console.print(users, overflow="ignore", crop=False)
user_renderables = [Panel(get_content(user), expand=True) for user in users]
print(Columns(user_renderables))
console.print(Columns(user_renderables))