mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix refresh on remove (#2008)
* fix refresh on remove * changelog * optimization * added snapshot
This commit is contained in:
38
tests/snapshot_tests/snapshot_apps/remove_auto.py
Normal file
38
tests/snapshot_tests/snapshot_apps/remove_auto.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Vertical
|
||||
from textual.widgets import Header, Footer, Label
|
||||
|
||||
|
||||
class VerticalRemoveApp(App[None]):
|
||||
CSS = """
|
||||
Vertical {
|
||||
border: round green;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
Label {
|
||||
border: round yellow;
|
||||
background: red;
|
||||
color: yellow;
|
||||
}
|
||||
"""
|
||||
BINDINGS = [
|
||||
("a", "add", "Add"),
|
||||
("d", "del", "Delete"),
|
||||
]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Vertical()
|
||||
yield Footer()
|
||||
|
||||
def action_add(self) -> None:
|
||||
self.query_one(Vertical).mount(Label("This is a test label"))
|
||||
|
||||
def action_del(self) -> None:
|
||||
if self.query_one(Vertical).children:
|
||||
self.query_one(Vertical).children[-1].remove()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
VerticalRemoveApp().run()
|
||||
Reference in New Issue
Block a user