Skip to content
Discussion options

You must be logged in to vote

If I'm reading this correctly (keep a widget hidden until some value is set on a property), perhaps a reactive along with a watch and some CSS magic?

from textual.app      import App, ComposeResult
from textual.widgets  import Header, Footer, Label
from textual.reactive import reactive

class MyLabel( Label ):

    DEFAULT_CSS = """
    .hidden {
        display: none;
    }
    """

    text: reactive[str | None] = reactive(None)

    def __init__( self ) -> None:
        super().__init__( classes="hidden" )

    def watch_text( self ) -> None:
        if self.text is not None:
            self.update( self.text )
        self.set_class( self.text is None, "hidden" )

class ReactShow( App[ 

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@davetapley
Comment options

@davep
Comment options

@davetapley
Comment options

@willmcgugan
Comment options

@davetapley
Comment options

Answer selected by davep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants