Skip to content

Commit 3db737b

Browse files
committed
expose grid-size
1 parent 17df56d commit 3db737b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/textual/layouts/grid.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def __init__(self) -> None:
2929
"""Shrink the grid to fit the container if it is larger."""
3030
self.auto_minimum: bool = False
3131
"""If self.shrink is `True`, auto-detect and limit the width."""
32+
self._grid_size: tuple[int, int] | None = None
33+
"""Grid size after last arrange call."""
34+
35+
@property
36+
def grid_size(self) -> tuple[int, int] | None:
37+
"""The grid size after the last arrange call.
38+
39+
Returns:
40+
A tuple of (WIDTH, HEIGHT) or `None` prior to the first `arrange`
41+
"""
42+
return self._grid_size
3243

3344
def arrange(
3445
self, parent: Widget, children: list[Widget], size: Size, greedy: bool = True
@@ -60,6 +71,9 @@ def arrange(
6071
table_size_columns -= 1
6172

6273
table_size_rows = styles.grid_size_rows
74+
75+
self._grid_size = (table_size_columns, table_size_rows)
76+
6377
viewport = parent.app.viewport_size
6478
keyline_style, _keyline_color = styles.keyline
6579
offset = (0, 0)

0 commit comments

Comments
 (0)