Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
✨ Test code for Textualize/textual#2007
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Mar 9, 2023
1 parent 9c9c445 commit 08d5eb3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions vertical_remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""https://github.com/Textualize/textual/issues/2007"""

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

0 comments on commit 08d5eb3

Please sign in to comment.