Skip to content

Commit b0656fd

Browse files
authored
Some docstrings for actions (#2172)
1 parent 2cd8295 commit b0656fd

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/textual/app.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,18 +2375,36 @@ async def action_pop_screen(self) -> None:
23752375
self.pop_screen()
23762376

23772377
async def action_back(self) -> None:
2378+
"""Go back to the previous screen (pop the current screen)."""
23782379
try:
23792380
self.pop_screen()
23802381
except ScreenStackError:
23812382
pass
23822383

23832384
async def action_add_class_(self, selector: str, class_name: str) -> None:
2385+
"""Add a CSS class on the selected widget.
2386+
2387+
Args:
2388+
selector: Selects the widget to add the class to.
2389+
class_name: The class to add to the selected widget.
2390+
"""
23842391
self.screen.query(selector).add_class(class_name)
23852392

23862393
async def action_remove_class_(self, selector: str, class_name: str) -> None:
2394+
"""Remove a CSS class on the selected widget.
2395+
2396+
Args:
2397+
selector: Selects the widget to remove the class from.
2398+
class_name: The class to remove from the selected widget."""
23872399
self.screen.query(selector).remove_class(class_name)
23882400

23892401
async def action_toggle_class(self, selector: str, class_name: str) -> None:
2402+
"""Toggle a CSS class on the selected widget.
2403+
2404+
Args:
2405+
selector: Selects the widget to toggle the class on.
2406+
class_name: The class to toggle on the selected widget.
2407+
"""
23902408
self.screen.query(selector).toggle_class(class_name)
23912409

23922410
def action_focus_next(self) -> None:

src/textual/scrollbar.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,21 @@ def _on_leave(self, event: events.Leave) -> None:
298298
self.mouse_over = False
299299

300300
def action_scroll_down(self) -> None:
301+
"""Scroll vertical scrollbars down, horizontal scrollbars right."""
301302
if not self.grabbed:
302303
self.post_message(ScrollDown() if self.vertical else ScrollRight())
303304

304305
def action_scroll_up(self) -> None:
306+
"""Scroll vertical scrollbars up, horizontal scrollbars left."""
305307
if not self.grabbed:
306308
self.post_message(ScrollUp() if self.vertical else ScrollLeft())
307309

308310
def action_grab(self) -> None:
311+
"""Begin capturing the mouse cursor."""
309312
self.capture_mouse()
310313

311314
def action_released(self) -> None:
315+
"""Finish capturing the mouse cursor"""
312316
self.capture_mouse(False)
313317

314318
async def _on_mouse_up(self, event: events.MouseUp) -> None:

0 commit comments

Comments
 (0)