Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] vertical alignment in table cells #1590

Closed
nschloe opened this issue Oct 15, 2021 · 2 comments
Closed

[REQUEST] vertical alignment in table cells #1590

nschloe opened this issue Oct 15, 2021 · 2 comments
Assignees

Comments

@nschloe
Copy link

nschloe commented Oct 15, 2021

From #1340.

It's currently not possible to vertically align cells in tables. Even rich.Align fails since the cells are rendered before the final height of the row is known.

Quoting @willmcgugan:

Probably the best way to solve that would be to add a vertical align option per cell, or column.

I'd make that "per cell, or column, or row, or table", but yeah.

MWE:

from rich.console import Console
from rich.table import Table
from rich.align import Align

console = Console()

table = Table(show_header=False)
table.add_row(
    # the order of the cells doesn't play a role here
    Align("Dev 20, 2019", vertical="middle"),
    "\n".join(["Star Wars: The Rise of Skywalker"] * 5),
)

console.print(table)
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Dev 20, 2019 ┃ Star Wars: The Rise of Skywalker ┃
┃              ┃ Star Wars: The Rise of Skywalker ┃
┃              ┃ Star Wars: The Rise of Skywalker ┃
┃              ┃ Star Wars: The Rise of Skywalker ┃
┃              ┃ Star Wars: The Rise of Skywalker ┃
└──────────────┴──────────────────────────────────┘
@willmcgugan
Copy link
Collaborator

See v11.0.0

You can set vertical alignment on a column. Or a cell.

@github-actions
Copy link

github-actions bot commented Jan 9, 2022

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jan 11, 2022
11.0.0

Added

Added max_depth arg to pretty printing Textualize/rich#1585
Added vertical_align to Table.add_row Textualize/rich#1590

Fixed

Fixed issue with pretty repr in jupyter notebook Textualize/rich#1717
Fix Traceback theme defaults override user supplied styles Textualize/rich#1786

Changed

breaking Deprecated rich.console.RenderGroup, now named rich.console.Group
breaking Syntax.__init__ parameter lexer_name renamed to lexer
Syntax constructor accepts both str and now a pygments lexer Textualize/rich#1748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants