Get a renderable that demonstrates a number of features.
()
| 37 | |
| 38 | |
| 39 | def make_test_card() -> Table: |
| 40 | """Get a renderable that demonstrates a number of features.""" |
| 41 | table = Table.grid(padding=1, pad_edge=True) |
| 42 | table.title = "Rich features" |
| 43 | table.add_column("Feature", no_wrap=True, justify="center", style="bold red") |
| 44 | table.add_column("Demonstration") |
| 45 | |
| 46 | color_table = Table( |
| 47 | box=None, |
| 48 | expand=False, |
| 49 | show_header=False, |
| 50 | show_edge=False, |
| 51 | pad_edge=False, |
| 52 | ) |
| 53 | color_table.add_row( |
| 54 | ( |
| 55 | "✓ [bold green]4-bit color[/]\n" |
| 56 | "✓ [bold blue]8-bit color[/]\n" |
| 57 | "✓ [bold magenta]Truecolor (16.7 million)[/]\n" |
| 58 | "✓ [bold yellow]Dumb terminals[/]\n" |
| 59 | "✓ [bold cyan]Automatic color conversion" |
| 60 | ), |
| 61 | ColorBox(), |
| 62 | ) |
| 63 | |
| 64 | table.add_row("Colors", color_table) |
| 65 | |
| 66 | table.add_row( |
| 67 | "Styles", |
| 68 | "All ansi styles: [bold]bold[/], [dim]dim[/], [italic]italic[/italic], [underline]underline[/], [strike]strikethrough[/], [reverse]reverse[/], and even [blink]blink[/].", |
| 69 | ) |
| 70 | |
| 71 | lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in metus sed sapien ultricies pretium a at justo. Maecenas luctus velit et auctor maximus." |
| 72 | lorem_table = Table.grid(padding=1, collapse_padding=True) |
| 73 | lorem_table.pad_edge = False |
| 74 | lorem_table.add_row( |
| 75 | Text(lorem, justify="left", style="green"), |
| 76 | Text(lorem, justify="center", style="yellow"), |
| 77 | Text(lorem, justify="right", style="blue"), |
| 78 | Text(lorem, justify="full", style="red"), |
| 79 | ) |
| 80 | table.add_row( |
| 81 | "Text", |
| 82 | Group( |
| 83 | Text.from_markup( |
| 84 | """Word wrap text. Justify [green]left[/], [yellow]center[/], [blue]right[/] or [red]full[/].\n""" |
| 85 | ), |
| 86 | lorem_table, |
| 87 | ), |
| 88 | ) |
| 89 | |
| 90 | def comparison(renderable1: RenderableType, renderable2: RenderableType) -> Table: |
| 91 | table = Table(show_header=False, pad_edge=False, box=None, expand=True) |
| 92 | table.add_column("1", ratio=1) |
| 93 | table.add_column("2", ratio=1) |
| 94 | table.add_row(renderable1, renderable2) |
| 95 | return table |
| 96 |