Skip to content

DataTable height issue #5424

@Tinche

Description

@Tinche

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.

# Textual Diagnostics

## Versions

| Name    | Value  |
|---------|--------|
| Textual | 1.0.0  |
| Rich    | 13.5.2 |

## Python

| Name           | Value                                                |
|----------------|------------------------------------------------------|
| Version        | 3.12.4                                               |
| Implementation | CPython                                              |
| Compiler       | Clang 16.0.0 (clang-1600.0.26.3)                     |
| Executable     | /Users/tintvrtkovic/ha/nlu_pipeline/.venv/bin/python |

## Operating System

| Name    | Value                                                                                            |
|---------|--------------------------------------------------------------------------------------------------|
| System  | Darwin                                                                                           |
| Release | 24.1.0                                                                                           |
| Version | Darwin Kernel Version 24.1.0: Thu Oct 10 21:02:27 PDT 2024; root:xnu-11215.41.3~2/RELEASE_X86_64 |

## Terminal

| Name                 | Value       |
|----------------------|-------------|
| Terminal Application | Kitty       |
| TERM                 | xterm-kitty |
| COLORTERM            | truecolor   |
| FORCE_COLOR          | *Not set*   |
| NO_COLOR             | *Not set*   |

## Rich Console options

| Name           | Value                |
|----------------|----------------------|
| size           | width=319, height=42 |
| legacy_windows | False                |
| min_width      | 1                    |
| max_width      | 319                  |
| is_terminal    | True                 |
| encoding       | utf-8                |
| max_height     | 42                   |
| justify        | None                 |
| overflow       | None                 |
| no_wrap        | False                |
| highlight      | None                 |
| markup         | None                 |
| height         | None                 |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions