1
1

NotificationList.py 738 B

1234567891011121314151617181920212223242526272829
  1. from pycs.frontend.notifications.NotificationManager import NotificationManager
  2. class NotificationList:
  3. """
  4. stores notifications to fire them later in the correct thread
  5. """
  6. def __init__(self, notifications: NotificationManager):
  7. self.__list = []
  8. self.notifications = notifications
  9. def add(self, fun: callable, *params):
  10. """
  11. add a function and parameters to be executed later
  12. :param fun: function
  13. :param params: parameters
  14. """
  15. self.__list.append((fun, *params))
  16. def fire(self):
  17. """
  18. fire all stored events and reset the list
  19. """
  20. for fun, *params in self.__list:
  21. fun(*params)
  22. self.__list = []