예제 #1
0
파일: signaling.py 프로젝트: vahndi/enaml
    def disconnect(self, slot):
        """ Disconnect the slot from the signal.

        If the slot was not previously connected, this is a no-op.

        Parameters
        ----------
        slot : callable
            The callable slot to disconnect from the signal.

        """
        if isinstance(slot, MethodType) and slot.im_self is not None:
            slot = CallableRef(WeakMethod(slot))
        _Disconnector(self._signal, self._objref)(slot)
예제 #2
0
    def disconnect(self, slot):
        """ Disconnect the slot from the signal.

        If the slot was not previously connected, this is a no-op.

        Parameters
        ----------
        slot : callable
            The callable slot to disconnect from the signal.

        """
        if isinstance(slot, MethodType) and slot.im_self is not None:
            slot = CallableRef(WeakMethod(slot))
        _Disconnector(self._signal, self._objref)(slot)
예제 #3
0
파일: signaling.py 프로젝트: vahndi/enaml
    def connect(self, slot):
        """ Connect the given slot to the signal.

        The slot will be called when the signal is emitted. It will be
        passed any positional and keyword arguments that were emitted
        with the signal. Multiple slots connected to a signal will be
        invoked in the order in which they were connected. Slots which
        are instance methods will be automatically disconnected when
        their underlying instance is garbage collected.

        Parameters
        ----------
        slot : callable
            The callable slot to invoke when the signal is emitted.

        """
        obj = self._objref()
        if obj is None:
            return
        dct = obj.__dict__
        key = _SIGNALS_KEY
        if key in dct:
            signals = dct[key]
        else:
            signals = dct[key] = {}
        signal = self._signal
        if signal in signals:
            slots = signals[signal]
            d = slots[0]
        else:
            d = _Disconnector(signal, self._objref)
            slots = signals[signal] = [d]
        if isinstance(slot, MethodType) and slot.im_self is not None:
            slot = CallableRef(WeakMethod(slot), d)
        slots.append(slot)
예제 #4
0
    def connect(self, slot):
        """ Connect the given slot to the signal.

        The slot will be called when the signal is emitted. It will be
        passed any positional and keyword arguments that were emitted
        with the signal. Multiple slots connected to a signal will be
        invoked in the order in which they were connected. Slots which
        are instance methods will be automatically disconnected when
        their underlying instance is garbage collected.

        Parameters
        ----------
        slot : callable
            The callable slot to invoke when the signal is emitted.

        """
        obj = self._objref()
        if obj is None:
            return
        dct = obj.__dict__
        key = _SIGNALS_KEY
        if key in dct:
            signals = dct[key]
        else:
            signals = dct[key] = {}
        signal = self._signal
        if signal in signals:
            slots = signals[signal]
            d = slots[0]
        else:
            d = _Disconnector(signal, self._objref)
            slots = signals[signal] = [d]
        if isinstance(slot, MethodType) and slot.im_self is not None:
            slot = CallableRef(WeakMethod(slot), d)
        slots.append(slot)