DataTable height issue #5425
-
Hi, it appears to me the DataTable widget has an issue with calculating its height. Here's a MRE: from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import DataTable, Input
class MyApp(App):
def compose(self) -> ComposeResult:
with Vertical():
yield Input()
table = DataTable[str](id="table")
table.add_columns("name", "value")
yield table
def on_mount(self) -> None:
self.query_exactly_one("#table", DataTable).add_rows([(i, i) for i in range(100)])
if __name__ == "__main__":
MyApp().run() Run this, tab over to the DataTable and try scrolling down. If the DataTable has greater height than the terminal, it will scroll, but there will be 3 rows off screen, at the bottom. The Input widget takes up 3 rows, so that might be a clue.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The DataTable has a height of auto. i.e. it will grow as you add rows. It has a max-height of 100%, which will mean it won't grow larger than the height of the container. If you want the DT to use the remaining height, set its height to |
Beta Was this translation helpful? Give feedback.
The DataTable has a height of auto. i.e. it will grow as you add rows. It has a max-height of 100%, which will mean it won't grow larger than the height of the container.
If you want the DT to use the remaining height, set its height to
1fr
.