How to use the toast.DefaultToast function in toast

To help you get started, we’ve selected a few toast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github illuminatedwax / pesterchum / toast.py View on Github external
if k == "libnotify":
                        if self.importance < 0:
                            t.set_urgency(pynotify.URGENCY_CRITICAL)
                        elif self.importance == 0:
                            t.set_urgency(pynotify.URGENCY_NORMAL)
                        elif self.importance > 0:
                            t.set_urgency(pynotify.URGENCY_LOW)
                    break
            if not t:
                if 'default' in self.machine.types:
                    if 'parent' in inspect.getargspec(self.machine.types['default'].__init__).args:
                        t = self.machine.types['default'](self.machine, self.title, self.msg, self.icon, self.machine.parent)
                    else:
                        t = self.machine.types['default'](self.machine, self.title, self.msg, self.icon)
                else:
                    t = DefaultToast(self.title, self.msg, self.icon)
            t.show()
github illuminatedwax / pesterchum / toast.py View on Github external
def showNext(self):
        if not self.displaying and self.toasts:
            self.toasts.sort(key=lambda x: x.importance)
            self.toasts[0].realShow()

    def showAll(self):
        while self.toasts:
            self.showNext()

    def run(self):
        while not self.quit:
            if self.on and self.toasts:
                self.showNext()


class PesterToast(DefaultToast):
    def __init__(self, machine, title, msg, icon, time=3000, parent=None):
        logging.info(isinstance(parent, QtWidgets.QWidget))
        kwds = dict(machine=machine, title=title, msg=msg, icon=icon)
        super().__init__(parent, **kwds)

        self.machine = machine
        self.time = time

        if ostools.isWin32():
            self.setWindowFlags(QtCore.Qt.ToolTip)
        else:
            self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.ToolTip)

        self.m_animation = QtCore.QParallelAnimationGroup()
        anim = QtCore.QPropertyAnimation(self, finished=self.reverseTrigger)
        anim.setTargetObject(self)
github illuminatedwax / pesterchum / toast.py View on Github external
def __init__(self, parent, name, on=True, type="default",
                                              types=({'default'  : DefaultToast,
                                                      'libnotify': pynotify.Notification}
                                                      if pynotify else
                                                      {'default' : DefaultToast}),
                                              extras={}):
        self.parent     = parent
        self.name       = name
        self.on         = on
        types.update(extras)
        self.types      = types
        self.type       = "default"
        self.quit       = False
        self.displaying = False

        self.setCurrentType(type)

        self.toasts = []