[PyQt] hang in pyqt5.7

oliver oliver.schoenborn at gmail.com
Sun Dec 25 22:44:00 GMT 2016


> > Being able to do something like this when some_signal is a pyqtSignal():
> >
> > assert self.some_signal.is_connected(some_object.slot)
>
> You could try and connect using the UniqueConnection type. If it fails
> then it is already connected.
>
> > assert self.some_signal.num_connections < 5
>
> Look at QObject.receivers().
>
> Phil


Thanks. BTW I've defined the following convenience function which I can
call while debugging, for sanity checks (for Python < 3.x, remove
annotations in def):

def is_connected(signal: pyqtSignal, slot: pyqtSlot):
    try:
        signal.connect(slot, Qt.UniqueConnection)

    except TypeError:
        return True

    else:
        signal.disconnect(slot)
        return False


Oliver
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161225/5681a81a/attachment.html>


More information about the PyQt mailing list