[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] hang in pyqt5.7
From:       oliver <oliver.schoenborn () gmail ! com>
Date:       2016-12-25 22:44:00
Message-ID: CAMb+DaWHEoyCYV7=RrP9+soJADknP4uodqh42yiSou+7Gx4nKQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> > 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

[Attachment #5 (text/html)]

<div dir="ltr"><div class="gmail_quote"><br><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> &gt; Being \
able to do something like this when some_signal is a pyqtSignal():<br \
class="gmail_msg"> &gt;<br class="gmail_msg">
&gt; assert self.some_signal.is_connected(some_object.slot)<br class="gmail_msg">
<br class="gmail_msg">
You could try and connect using the UniqueConnection type. If it fails then it is \
already connected.<br class="gmail_msg"> <br class="gmail_msg">
&gt; assert self.some_signal.num_connections &lt; 5<br class="gmail_msg">
<br class="gmail_msg">
Look at QObject.receivers().<br class="gmail_msg">
<br class="gmail_msg">
Phil</blockquote><div><br></div><div>Thanks. BTW I&#39;ve defined the following \
convenience function which I can call while debugging, for sanity checks (for Python \
&lt; 3.x, remove annotations in def):  </div><div><br></div><div><font size="1" \
face="monospace">def is_connected(signal: pyqtSignal, slot: \
pyqtSlot):</font></div><div><font size="1" face="monospace">      \
try:</font></div><div><font size="1" face="monospace">            \
signal.connect(slot, Qt.UniqueConnection)<br></font></div><div><font size="1" \
face="monospace"><br></font></div><div><font size="1" face="monospace">      except \
TypeError:</font></div><div><font size="1" face="monospace">            return \
True</font></div><div><font size="1" face="monospace"><br></font></div><div><font \
size="1" face="monospace">      else:</font></div><div><font size="1" \
face="monospace">            signal.disconnect(slot)</font></div><div><font size="1" \
face="monospace">            return False</font></div><div><br></div><div>  \
</div><div>Oliver</div></div></div><div dir="ltr">-- <br></div><div \
data-smartmail="gmail_signature"><div dir="ltr">Oliver<div>My StackOverflow \
contributions<br><div>My CodeProject articles</div></div><div>My Github \
projects</div><div>My SourceForget.net projects</div></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic