How to use the toast.ToastMachine 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
curspace = text.find(" ", lastspace+1)
                if curspace == -1:
                    break
            if (metric.width(text[:lastspace]) > maxwidth) or \
               len(text[:lastspace]) < 1:
                for i in range(len(text)):
                    if metric.width(text[:i]) > maxwidth:
                        lastspace = i-1
                        break
            ret.append(text[:lastspace])
            text = text[lastspace+1:]
        ret.append(text)
        return "\n".join(ret)


class PesterToastMachine(ToastMachine, QtCore.QObject):
    def __init__(self, parent, name, on=True, type="default",
                 types=({'default'  : DefaultToast,
                        'libnotify' : pynotify.Notification}
                        if pynotify else
                        {'default' : DefaultToast}),
                 extras={}):
        ToastMachine.__init__(self, parent, name, on, type, types, extras)
        QtCore.QObject.__init__(self, parent)

    def setEnabled(self, on):
        oldon = self.on
        ToastMachine.setEnabled(self, on)
        if oldon != self.on:
            self.parent.config.set('notify', self.on)
            if self.on:
                self.timer.start()