How to use toast - 10 common examples

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 klange / toaruos / userspace / py / bin / toastd.py View on Github external
print(f"Toast daemon already running or /dev/pex/{daemon} not closed properly.")
        sys.exit(1)

    os.environ['TOASTD'] = daemon
    pex_server = pex.PexServer(daemon)

    fds = [yutani.yutani_ctx,pex_server]
    while 1:
        # Poll for events.
        fd = fswait.fswait(fds,20 if sliding else 500)

        if fd == 1:
            size, packet = pex_server.listen()
            if size and packet.size:
                data = ctypes.addressof(packet) + pex.pex_packet.data.offset
                notification = Notification(toast.ToastMessage.from_address(data))
                notifications.append(notification)
        check_close()
        while yutani.yutani_ctx.query():
            msg = yutani.yutani_ctx.poll()
            if not yutani_mainloop.handle_event(msg):
                os.unlink('/dev/pex/'+daemon)
                sys.exit(0)
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={}):
        ToastMachine.__init__(self, parent, name, on, type, types, extras)
        QtCore.QObject.__init__(self, parent)
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()
github illuminatedwax / pesterchum / toast.py View on Github external
def showNext(self):
        ToastMachine.showNext(self)
github illuminatedwax / pesterchum / toast.py View on Github external
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()
            else:
                self.timer.stop()
github illuminatedwax / pesterchum / toast.py View on Github external
def setCurrentType(self, type):
        oldtype = self.type
        ToastMachine.setCurrentType(self, type)
        if oldtype != self.type:
            self.parent.config.set('notifyType', self.type)
github knappador / billing-example / app / billing / androidbilling.py View on Github external
def _toast(self, text, length_long=False):
        if self.toasty:
            toast.toast(text, length_long)
github inclement / noGo / noGo / main.py View on Github external
def new_board(self, sgf_model=None, collection_model=None, from_file='', mode='Play', gridsize=19, handicap=0, goto=True):
        toast('Loading sgf', False)
        load_from_file = False

        t1 = time()

        # Get a collection and collectionsgf to contain and represent the board 
        filen = from_file
        if sgf_model is not None:
            sgf = sgf_model
            if sgf.filename:
                filen = sgf.filename
            load_from_file = True
        elif collection_model is not None:
            sgf = Sgf()
            sgf.save()
            collectionsgf = CollectionSgf(collection=collection_model, sgf=sgf)
            collectionsgf.save()
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)