Skip to content

How to delete child widgets? #5234

Closed Answered by YoonSungHyun-Git
YoonSungHyun-Git asked this question in Q&A
Discussion options

You must be logged in to vote

This is an advisory answer.
remove_children(selector='*') returns awaitable, so use await.

import random
from textual import on
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll, Container
from textual.widgets import Header, Footer, Button, Static
from textual.reactive import reactive

class Test(App):
    def compose(self) -> ComposeResult:
        yield Header(id="header")
        yield Footer()
        yield Button(f"Add", id="btn_add", variant="primary")
        
        with Container(id="main-grid"):
            with VerticalScroll(id="right-rich"):
                pass

    @on(Button.Pressed, "#btn_add")
    async def add_scope(self, event: B…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YoonSungHyun-Git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant