Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable height issue #5424

Closed
Tinche opened this issue Dec 22, 2024 · 1 comment
Closed

DataTable height issue #5424

Tinche opened this issue Dec 22, 2024 · 1 comment

Comments

@Tinche
Copy link

Tinche commented Dec 22, 2024

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                 |
@Textualize Textualize deleted a comment from github-actions bot Dec 22, 2024
@willmcgugan
Copy link
Collaborator

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.

@Textualize Textualize locked and limited conversation to collaborators Dec 22, 2024
@willmcgugan willmcgugan converted this issue into discussion #5425 Dec 22, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants