mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Return the StringKey objects from add_row/add_column in DataTable
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user