fix actions

This commit is contained in:
Will McGugan
2021-08-13 21:32:45 +01:00
parent 7140df6418
commit 01e61d600c
2 changed files with 7 additions and 6 deletions

View File

@@ -7,18 +7,18 @@ from textual.widgets import Footer, Placeholder
class SmoothApp(App):
"""Demonstrates smooth animation. Press 'b' to see it in action."""
async def on_load(self, event: events.Load) -> None:
async def on_load(self) -> None:
"""Bind keys here."""
await self.bind("b", "toggle_sidebar", "Toggle sidebar")
await self.bind("q", "quit", "Quit")
show_bar: Reactive[bool] = Reactive(False)
show_bar = Reactive(False)
async def watch_show_bar(self, show_bar: bool) -> None:
def watch_show_bar(self, show_bar: bool) -> None:
"""Called when show_bar changes."""
self.bar.animate("layout_offset_x", 0 if show_bar else -40)
async def action_toggle_sidebar(self) -> None:
def action_toggle_sidebar(self) -> None:
"""Called when user hits 'b' key."""
self.show_bar = not self.show_bar