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

Can't interact with DataTable after loading state in macOS Terminal.app #3910

Closed
frankie567 opened this issue Dec 20, 2023 · 1 comment
Closed

Comments

@frankie567
Copy link

When mounting a DataTable, it can directly be interacted with using arrow keys on the keyboard (I suppose it gets automatic focus).

However, this behavior breaks under macOS Terminal.app, after switching the loading state. When loading is set to False, the table appears but the arrow keys have no effect.

With WezTerm, keyboard input is also inactive after loading, but since it detects the mouse cursor (contrary to Terminal.app), the "focus" can be revived.

Reproducible example

from asyncio import sleep
from random import randint

from textual import work
from textual.app import App, ComposeResult
from textual.widgets import DataTable

ROWS = [
    ("lane", "swimmer", "country", "time"),
    (4, "Joseph Schooling", "Singapore", 50.39),
    (2, "Michael Phelps", "United States", 51.14),
    (5, "Chad le Clos", "South Africa", 51.14),
    (6, "László Cseh", "Hungary", 51.14),
    (3, "Li Zhuhao", "China", 51.26),
    (8, "Mehdy Metella", "France", 51.58),
    (7, "Tom Shields", "United States", 51.73),
    (1, "Aleksandr Sadovnikov", "Russia", 51.84),
    (10, "Darren Burns", "Scotland", 51.84),
]


class DataApp(App):
    CSS = """
    DataTable {
        height: 1fr;
    }
    """

    def compose(self) -> ComposeResult:
        yield DataTable()

    def on_mount(self) -> None:
        data_table = self.query_one(DataTable)
        data_table.loading = True
        self.load_data()

    @work
    async def load_data(self) -> None:
        await sleep(randint(2, 10))
        data_table = self.query_one(DataTable)
        data_table.add_columns(*ROWS[0])
        data_table.add_rows(ROWS[1:])
        data_table.loading = False


if __name__ == "__main__":
    app = DataApp()
    app.run()

Textual Diagnostics

Versions

Name Value
Textual 0.46.0
Rich 13.7.0

Python

Name Value
Version 3.12.0
Implementation CPython
Compiler Clang 15.0.0 (clang-1500.0.40.1)
Executable /Users/fvoron/Development/polar/server/.venv/bin/python

Operating System

Name Value
System Darwin
Release 23.1.0
Version Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000

Terminal

Name Value
Terminal Application Apple_Terminal (452)
TERM xterm-256color
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=245, height=62
legacy_windows False
min_width 1
max_width 245
is_terminal True
encoding utf-8
max_height 62
justify None
overflow None
no_wrap False
highlight None
markup None
height None
Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@Textualize Textualize locked and limited conversation to collaborators Dec 20, 2023
@davep davep converted this issue into discussion #3911 Dec 20, 2023

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

1 participant