mirror of https://github.com/Textualize/rich.git
ignore overflow in columns example
This commit is contained in:
parent
8e94315c3b
commit
eadc162feb
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue