Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The following people have contributed to the development of Rich:
- [Damian Shaw](https://github.com/notatallshaw)
- [Nicolas Simonds](https://github.com/0xDEC0DE)
- [Aaron Stephens](https://github.com/aaronst)
- [Stranger](https://github.com/Stranger-Jie)
- [Karolina Surma](https://github.com/befeleme)
- [Gabriele N. Tornetta](https://github.com/p403n1x87)
- [Nils Vu](https://github.com/nilsvu)
Expand Down
24 changes: 23 additions & 1 deletion rich/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .align import Align, AlignMethod
from .console import Console, ConsoleOptions, RenderableType, RenderResult
from .constrain import Constrain
from .measure import Measurement
from .measure import Measurement, measure_renderables
from .padding import Padding, PaddingDimensions
from .table import Table
from .text import TextType
Expand Down Expand Up @@ -170,6 +170,28 @@ def iter_renderables(
add_row(*row)
yield table

def __rich_measure__(
self, console: "Console", options: "ConsoleOptions"
) -> "Measurement":
title = self.title
_, right, _, left = Padding.unpack(self.padding)
padding = left + right
renderables = [*self.renderables, title] if title else [*self.renderables]

if self.width is None:
width = (
measure_renderables(
console,
options.update_width(options.max_width - padding - 2),
renderables,
).maximum
+ padding
+ 2
)
else:
width = self.width
return Measurement(width, width)


if __name__ == "__main__": # pragma: no cover
import os
Expand Down