mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Removing redundant data from DataTable.Row
This commit is contained in:
@@ -117,7 +117,6 @@ class Row:
|
|||||||
|
|
||||||
key: RowKey
|
key: RowKey
|
||||||
height: int
|
height: int
|
||||||
y: int
|
|
||||||
cell_renderables: list[RenderableType] = field(default_factory=list)
|
cell_renderables: list[RenderableType] = field(default_factory=list)
|
||||||
|
|
||||||
|
|
||||||
@@ -606,13 +605,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
|
|||||||
column.key: cell
|
column.key: cell
|
||||||
for column, cell in zip_longest(self._ordered_columns, cells)
|
for column, cell in zip_longest(self._ordered_columns, cells)
|
||||||
}
|
}
|
||||||
self.rows[row_key] = Row(row_key, height, self._line_no)
|
self.rows[row_key] = Row(row_key, height)
|
||||||
|
|
||||||
# for line_no in range(height):
|
|
||||||
# self._y_offsets.append((row_key, line_no))
|
|
||||||
|
|
||||||
self._line_no += height
|
|
||||||
|
|
||||||
self._new_rows.add(row_index)
|
self._new_rows.add(row_index)
|
||||||
self._require_update_dimensions = True
|
self._require_update_dimensions = True
|
||||||
self.cursor_cell = self.cursor_cell
|
self.cursor_cell = self.cursor_cell
|
||||||
@@ -754,7 +747,6 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
|
|||||||
# Ensure we order the cells in the row based on current column ordering
|
# Ensure we order the cells in the row based on current column ordering
|
||||||
row_key = self._row_locations.get_key(row_index)
|
row_key = self._row_locations.get_key(row_index)
|
||||||
cell_mapping: dict[ColumnKey, CellType] = self.data.get(row_key)
|
cell_mapping: dict[ColumnKey, CellType] = self.data.get(row_key)
|
||||||
print(row_index, cell_mapping.values())
|
|
||||||
|
|
||||||
ordered_row: list[CellType] = []
|
ordered_row: list[CellType] = []
|
||||||
for column in ordered_columns:
|
for column in ordered_columns:
|
||||||
@@ -823,7 +815,6 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
|
|||||||
style += Style.from_meta({"row": row_index, "column": column_index})
|
style += Style.from_meta({"row": row_index, "column": column_index})
|
||||||
height = self.header_height if is_header_row else self.rows[row_key].height
|
height = self.header_height if is_header_row else self.rows[row_key].height
|
||||||
cell = self._get_row_renderables(row_index)[column_index]
|
cell = self._get_row_renderables(row_index)[column_index]
|
||||||
print(f"CELL = {cell}")
|
|
||||||
lines = self.app.console.render_lines(
|
lines = self.app.console.render_lines(
|
||||||
Padding(cell, (0, 1)),
|
Padding(cell, (0, 1)),
|
||||||
self.app.console.options.update_dimensions(width, height),
|
self.app.console.options.update_dimensions(width, height),
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -165,7 +165,7 @@ async def test_add_rows_user_defined_keys():
|
|||||||
third_row = {key_a: ROWS[2][0], key_b: ROWS[2][1]}
|
third_row = {key_a: ROWS[2][0], key_b: ROWS[2][1]}
|
||||||
assert table.data[auto_key] == third_row
|
assert table.data[auto_key] == third_row
|
||||||
|
|
||||||
first_row = Row(algernon_key, height=1, y=0)
|
first_row = Row(algernon_key, height=1)
|
||||||
assert table.rows[algernon_key] == first_row
|
assert table.rows[algernon_key] == first_row
|
||||||
assert table.rows["algernon"] == first_row
|
assert table.rows["algernon"] == first_row
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user