Skip to content

Commit 8769a03

Browse files
committed
[WIP] use rich.measure.Measurement
1 parent 71ad4ac commit 8769a03

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pyhdtoolkit/scripts/htc_monitor.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from rich.console import Console, Group
2525
from rich.layout import Layout
2626
from rich.live import Live
27+
from rich.measure import Measurement
2728
from rich.panel import Panel
2829
from rich.progress import BarColumn, Progress, TextColumn, TimeRemainingColumn
2930
from typer import Option, Typer
@@ -110,12 +111,12 @@ def make_layout(progress: Progress, tables: Group, console: Console) -> Layout:
110111
"""
111112
# Compute max width among all panels in the Group
112113
table_width: int = max( # we add +2 for panel padding/borders
113-
getattr(panel.renderable, "width", 0) + 2 # ty:ignore[unresolved-attribute]
114+
Measurement.get(console, console.options, panel.renderable).maximum # ty:ignore[unresolved-attribute]
114115
for panel in tables.renderables
115116
)
116117

117-
# Ensure the panel doesn't exceed the console width
118-
panel_width: int = min(table_width, console.width - 2)
118+
# Add panel borders and padding (2 for border + 2 for padding)
119+
panel_width: int = min(table_width + 4, console.width)
119120

120121
layout = Layout()
121122
layout.split_column(

0 commit comments

Comments
 (0)