Is there any way to get the height of a panel programmatically? #1767
-
I need to get the height of a panel inside of a layout. I've looked through the documentation and wasn't able to find anything. Here's an example of what I am trying to do: from rich.layout import Layout
from rich.panel import Panel
layout = Layout()
layout.split_column(
Panel("something"),
Panel("another_thing")
)
something_height: int = layout["something"].height |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The If you want to know the available height within a Panel you can define a console renderable with a |
Beta Was this translation helpful? Give feedback.
The
Panel.height
is used to force the height in advance. It's not to report the height as it is rendered.If you want to know the available height within a Panel you can define a console renderable with a
__rich_console__
method. See the docs for how to define a console renderable. Theoptions
parameter will have amax_height
attribute which is the number of lines available.