Return the StringKey objects from add_row/add_column in DataTable

This commit is contained in:
Darren Burns
2023-01-19 15:16:22 +00:00
parent 9d7e8a8d4d
commit 27734d5fdb

View File

@@ -461,7 +461,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
def add_column(
self, label: TextType, *, width: int | None = None, key: str | None = None
) -> None:
) -> StringKey:
"""Add a column to the table.
Args:
@@ -495,9 +495,11 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
self._require_update_dimensions = True
self.check_idle()
return column_key
def add_row(
self, *cells: CellType, height: int = 1, key: str | None = None
) -> None:
) -> StringKey:
"""Add a row at the bottom of the DataTable.
Args:
@@ -531,6 +533,8 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
if cell_now_available and visible_cursor:
self._highlight_cursor()
return row_key
def add_columns(self, *labels: TextType) -> None:
"""Add a number of columns.