From b0656fd6062e46243b8d5584837e13b35e405a2c Mon Sep 17 00:00:00 2001 From: darrenburns Date: Thu, 30 Mar 2023 10:18:19 +0100 Subject: [PATCH] Some docstrings for actions (#2172) --- src/textual/app.py | 18 ++++++++++++++++++ src/textual/scrollbar.py | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/textual/app.py b/src/textual/app.py index 52e631416..17c75ffb5 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -2375,18 +2375,36 @@ class App(Generic[ReturnType], DOMNode): self.pop_screen() async def action_back(self) -> None: + """Go back to the previous screen (pop the current screen).""" try: self.pop_screen() except ScreenStackError: pass async def action_add_class_(self, selector: str, class_name: str) -> None: + """Add a CSS class on the selected widget. + + Args: + selector: Selects the widget to add the class to. + class_name: The class to add to the selected widget. + """ self.screen.query(selector).add_class(class_name) async def action_remove_class_(self, selector: str, class_name: str) -> None: + """Remove a CSS class on the selected widget. + + Args: + selector: Selects the widget to remove the class from. + class_name: The class to remove from the selected widget.""" self.screen.query(selector).remove_class(class_name) async def action_toggle_class(self, selector: str, class_name: str) -> None: + """Toggle a CSS class on the selected widget. + + Args: + selector: Selects the widget to toggle the class on. + class_name: The class to toggle on the selected widget. + """ self.screen.query(selector).toggle_class(class_name) def action_focus_next(self) -> None: diff --git a/src/textual/scrollbar.py b/src/textual/scrollbar.py index abb668bb4..1d590e2ed 100644 --- a/src/textual/scrollbar.py +++ b/src/textual/scrollbar.py @@ -298,17 +298,21 @@ class ScrollBar(Widget): self.mouse_over = False def action_scroll_down(self) -> None: + """Scroll vertical scrollbars down, horizontal scrollbars right.""" if not self.grabbed: self.post_message(ScrollDown() if self.vertical else ScrollRight()) def action_scroll_up(self) -> None: + """Scroll vertical scrollbars up, horizontal scrollbars left.""" if not self.grabbed: self.post_message(ScrollUp() if self.vertical else ScrollLeft()) def action_grab(self) -> None: + """Begin capturing the mouse cursor.""" self.capture_mouse() def action_released(self) -> None: + """Finish capturing the mouse cursor""" self.capture_mouse(False) async def _on_mouse_up(self, event: events.MouseUp) -> None: