Skip to content
Discussion options

You must be logged in to vote

The suggestion was to call call_after_refresh from inside a on_resize. For example:

from textual.app import App, ComposeResult
from textual.widgets import Static

class WidgetSizeApp(App[None]):

    CSS = """
    #fr1 {
        height: 1fr;
    }
    #fr2 {
        height: 2fr;
    }
    """

    def compose(self) -> ComposeResult:
        yield Static(id="fr1")
        yield Static(id="fr2")

    def on_mount(self) -> None:
        self.call_after_refresh(self.show_sizes)

    def on_resize(self) -> None:
        self.call_after_refresh(self.show_sizes)

    def show_sizes(self) -> None:
        for widget in self.query(Static):
            widget.update(f"{widget.size!r}")

if __name__ ==

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@SkwalExe
Comment options

@davep
Comment options

Answer selected by SkwalExe
@davep
Comment options

@SkwalExe
Comment options

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