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

1"""Notifications.""" 

2 

3from textual.app import App 

4 

5 

6class NotifyMixin: 

7 """Mixin class to add notify methods.""" 

8 

9 app: App 

10 

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) 

14 

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) 

18 

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) 

22 

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)