Created
August 6, 2023 09:12
-
-
Save shuckc/4b5a2650b9853c7564541c5a0ed942a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from textual.app import App, ComposeResult | |
from textual.widgets import DataTable | |
from typing import Dict | |
ROWS = [ | |
(4, "Joseph Schooling", "Singapore", 50.39), | |
(1, "Aleksandr Sadovnikov", "Russia", 51.84), | |
(10, "Darren Burns", "Scotland", 51.84), | |
] | |
class TableApp(App): | |
def __init__(self): | |
super().__init__() | |
self.rowkeys: Dict[int,RowKey] = {} | |
def compose(self) -> ComposeResult: | |
yield DataTable() | |
def on_mount(self) -> None: | |
table = self.query_one(DataTable) | |
table.add_columns("lane", "swimmer", "country", "time") | |
for i,r in enumerate(ROWS): | |
rk = table.add_row(*r) | |
self.rowkeys[i] = rk | |
app = TableApp() | |
if __name__ == "__main__": | |
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mypy --check-untyped-defs dt_test.py | |
dt_test.py:15: error: Name "RowKey" is not defined [name-defined] | |
Found 1 error in 1 file (checked 1 source file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK with
from textual.widgets._data_table import RowKey
added, I get clean output: