Coverage for src/devboard/notifications.py: 63.64%
11 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-19 20:21 +0100
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-19 20:21 +0100
1"""Notifications."""
3from textual.app import App
6class NotifyMixin:
7 """Mixin class to add notify methods."""
9 app: App
11 def notify_info(self, message: str, timeout: float = 3.0) -> None:
12 """Notify information."""
13 self.app.notify(f"[b blue]INFO[/] {message}", severity="information", timeout=timeout)
15 def notify_success(self, message: str, timeout: float = 3.0) -> None:
16 """Notify success."""
17 self.app.notify(f"[b green]SUCCESS[/] {message}", severity="information", timeout=timeout)
19 def notify_warning(self, message: str, timeout: float = 3.0) -> None:
20 """Notify warning."""
21 self.app.notify(f"[b yellow]WARNING[/] {message}", severity="warning", timeout=timeout)
23 def notify_error(self, message: str, timeout: float = 3.0) -> None:
24 """Notify error."""
25 self.app.notify(f"[b red]ERROR[/] {message}", severity="error", timeout=timeout)