Skip to content

Enable animation of offset with a tuple #3028

Open
@TomJGooding

Description

@TomJGooding

The docs say that "You can apply animations to styles such as offset to move widgets around the screen".

But how?

I found this discussion #1569 from back in January, which suggests this might be a bug?

from textual.app import App, ComposeResult
from textual.geometry import Offset
from textual.widgets import Footer, Static


class ExampleApp(App):
    BINDINGS = [("space", "animate_offset", "Animate Offet")]

    CSS = """
    Screen {
        align: center middle;
    }

    Static {
        background: red;
        width: auto;
        height: 3;
        content-align: center middle;
    }
    """

    def compose(self) -> ComposeResult:
        yield Static("Animate me!")
        yield Footer()

    def action_animate_offset(self) -> None:
        static = self.query_one(Static)
        static.styles.animate(
            attribute="offset",
            value=Offset(10, 10),  # crashes
            # value="10 10",  # crashes
            # value=(10, 10),  # crashes
            duration=0.5,
        )


if __name__ == "__main__":
    app = ExampleApp()
    app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions