diff --git a/examples/columns.py b/examples/columns.py index 2c1b9bfb..3fcde8f5 100644 --- a/examples/columns.py +++ b/examples/columns.py @@ -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))