fix refresh on remove (#2008)

* fix refresh on remove

* changelog

* optimization

* added snapshot
This commit is contained in:
Will McGugan
2023-03-10 10:06:10 +00:00
committed by GitHub
parent e2c36c4a15
commit d3bdaf8ae5
7 changed files with 221 additions and 7 deletions

View 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()