Test cell_padding assignment refreshes data table.
This commit is contained in:
parent
b84334c23b
commit
bbe5c85daa
4 changed files with 177 additions and 0 deletions
|
|
@ -330,6 +330,9 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
|
|||
)
|
||||
"""The coordinate of the `DataTable` that is being hovered."""
|
||||
|
||||
def watch_cell_padding(self) -> None:
|
||||
self._clear_caches()
|
||||
|
||||
class CellHighlighted(Message):
|
||||
"""Posted when the cursor moves to highlight a new cell.
|
||||
|
||||
|
|
@ -1052,6 +1055,9 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
|
|||
def watch_zebra_stripes(self) -> None:
|
||||
self._clear_caches()
|
||||
|
||||
def watch_cell_padding(self) -> None:
|
||||
self._clear_caches()
|
||||
|
||||
def watch_hover_coordinate(self, old: Coordinate, value: Coordinate) -> None:
|
||||
self.refresh_coordinate(old)
|
||||
self.refresh_coordinate(value)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -16,6 +16,12 @@ class TableApp(App):
|
|||
dt.add_row("value", "value", "val")
|
||||
yield dt
|
||||
|
||||
def key_a(self):
|
||||
self.query(DataTable).last().cell_padding = 20
|
||||
|
||||
def key_b(self):
|
||||
self.query(DataTable).last().cell_padding = 10
|
||||
|
||||
|
||||
app = TableApp()
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -172,6 +172,13 @@ def test_datatable_cell_padding(snap_compare):
|
|||
assert snap_compare(SNAPSHOT_APPS_DIR / "data_table_cell_padding.py")
|
||||
|
||||
|
||||
def test_datatable_change_cell_padding(snap_compare):
|
||||
# Check that horizontal cell padding is respected.
|
||||
assert snap_compare(
|
||||
SNAPSHOT_APPS_DIR / "data_table_cell_padding.py", press=["a", "b"]
|
||||
)
|
||||
|
||||
|
||||
def test_footer_render(snap_compare):
|
||||
assert snap_compare(WIDGET_EXAMPLES_DIR / "footer.py")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue