notify.py 1.2 KB

123456789101112131415161718192021222324252627
  1. from typing import Optional, Union
  2. from .. import globals
  3. from ..task_logger import create_task
  4. def notify(message: str, *,
  5. position: str = 'bottom',
  6. closeBtn: Union[bool, str] = False,
  7. type: Optional[str] = None,
  8. color: Optional[str] = None,
  9. **kwargs,
  10. ) -> None:
  11. """Notification
  12. Displays a notification on the screen.
  13. :param message: content of the notification
  14. :param position: position on the screen ("top-left", "top-right", "bottom-left", "bottom-right, "top", "bottom", "left", "right" or "center", default: "bottom")
  15. :param closeBtn: optional label of a button to dismiss the notification (default: `False`)
  16. :param type: optional type ("positive", "negative", "warning", "info" or "ongoing")
  17. :param color: optional color name
  18. Note: You can pass additional keyword arguments according to [Quasar's Notify API](https://quasar.dev/quasar-plugins/notify#notify-api).
  19. """
  20. options = {key: value for key, value in locals().items() if not key.startswith('_') and value is not None}
  21. create_task(globals.sio.emit('notify', options, room=str(globals.get_client().id)))