Is it possible to configure rich.Layout() to indicate when the number of items in the layout has exceeded the display size of the current layout?
I would like to be able to tell programmatically when the code is attempting to display too many items for the current Table/Layout to display in order to display ellipsis or a message such as "...and 200 further items". This would allow the program to alert the user that some items are not being displayed.
There is a size
attribute in Layout, but that value appears to be an input to constrain the layout to a fixed size rather than an indicator of the current Layout size.
In my current application, I would rather not constrain the size of the Layout in order to use the full available layout size, whatever that value may be.
#!/usr/bin/env python3
from rich.console import Console
from rich.layout import Layout
from rich.table import Table
from rich.pretty import Pretty
# Make too many lines for the Layout/Table to display on the current screen size
MAX_LINES = 1000
def fill_table():
table = Table()
for li in range(MAX_LINES):
table.add_row(Pretty(li))
return table
console = Console()
layout = Layout(name="root")
layout["root"].update(fill_table())
console.print(layout)