Closed epi052 closed 1 year ago
Offset should be a textual.geometry.Offset
object.
I'll see if we can raise a better error.
@willmcgugan Just flagging up that after the recent work on animations, this particular situation still throws the error. Testing with this:
from textual.app import App, ComposeResult
from textual.geometry import Offset
from textual.widgets import Static
from textual.containers import Container
class Demo(App):
TITLE = "Demonstration"
BINDINGS = [
("b", "toggle_sidebar", "Sidebar"),
]
CSS = """
#sidebar {
width: 40;
background: $panel;
}
"""
def compose(self) -> ComposeResult:
self.bar = Container(Static("Textual Demo"), id="sidebar")
yield self.bar
def action_toggle_sidebar(self) -> None:
self.bar.styles.animate("offset", value=Offset( 0, 0 ), duration=2.5)
if __name__ == "__main__":
Demo().run()
I'm also getting a similar error when trying to animate the width
.
from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Static
class Demo(App):
TITLE = "Demonstration"
BINDINGS = [
("b", "toggle_sidebar", "Sidebar"),
]
CSS = """
#sidebar {
width: 40;
background: $panel;
}
"""
def compose(self) -> ComposeResult:
self.bar = Container(Static("Textual Demo"), id="sidebar")
yield self.bar
def action_toggle_sidebar(self) -> None:
self.bar.styles.animate("width", value=0, duration=2.5)
if __name__ == "__main__":
Demo().run()
AssertionError: `start_value` must be float, not Scalar(value=40.0, unit=<Unit.CELLS: 1>, percent_unit=<Unit.WIDTH: 4>)
Last example works. Assuming fixed.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
I was playing around with animating a dock's slide and tried to do it programmatically. When calling
.animate
onoffset
, I get the assertion error shown below. Changingoffset
toopacity
shows a working animation.This could absolutely be user-error, however, the asserted value isn't something I see as controllable from the user's api.