-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Checking in remove_row progress * Ensuring structures updated correctly when row deleted * Clamping index * Failed attempt * Removing rows * Update a type hint in DataTable * Remove some code that wasnt required * Use index syntax instead of get * Add DataTable remove row test * Snapshot tests for removing rows * Add a docstring for DataTable.remove_row method * Update changelog regarding DataTable.remove_row * Add check_idle call to remove_row
- Loading branch information
1 parent
1393949
commit 6352ceb
Showing
7 changed files
with
273 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
tests/snapshot_tests/snapshot_apps/data_table_remove_row.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.binding import Binding | ||
from textual.widgets import DataTable | ||
|
||
ROWS = [ | ||
("lane", "swimmer", "country", "time"), | ||
(5, "Chad le Clos", "South Africa", 51.14), | ||
(4, "Joseph Schooling", "Singapore", 50.39), | ||
(2, "Michael Phelps", "United States", 51.14), | ||
(6, "László Cseh", "Hungary", 51.14), | ||
(3, "Li Zhuhao", "China", 51.26), | ||
(8, "Mehdy Metella", "France", 51.58), | ||
(7, "Tom Shields", "United States", 51.73), | ||
(10, "Darren Burns", "Scotland", 51.84), | ||
(1, "Aleksandr Sadovnikov", "Russia", 51.84), | ||
] | ||
|
||
|
||
class TableApp(App): | ||
"""Snapshot app for testing removal of rows. | ||
Removes several rows, so we can check that the display of the | ||
DataTable updates as expected.""" | ||
|
||
BINDINGS = [ | ||
Binding("r", "remove_row", "Remove Row"), | ||
] | ||
|
||
def compose(self) -> ComposeResult: | ||
yield DataTable() | ||
|
||
def on_mount(self) -> None: | ||
table = self.query_one(DataTable) | ||
table.focus() | ||
rows = iter(ROWS) | ||
column_labels = next(rows) | ||
for column in column_labels: | ||
table.add_column(column, key=column) | ||
|
||
for row in rows: | ||
table.add_row(*row, key=str(row[0])) | ||
|
||
def action_remove_row(self): | ||
table = self.query_one(DataTable) | ||
table.remove_row("2") | ||
table.remove_row("8") | ||
table.remove_row("1") | ||
|
||
|
||
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
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