Add pyqtBoundSignal.signal: str#51
Conversation
|
Could you please add a description to your PR to help others understand why you made the change. Thanks :) |
|
Over in QTrio I am comparing bound signals against each other to see if they are 'the same signal'. While PySide2 already implements this, PyQt5 did not (though it will be in the next release). I wrote the workaround below which uses the https://www.riverbankcomputing.com/pipermail/pyqt/2020-July/043064.html def is_from(self, signal: SignalInstance) -> bool:
"""Check if this emission came from `signal`.
Args:
signal: The signal instance to check for being the source.
"""
# TODO: `repr()` here seems really bad.
if qtpy.PYQT5:
return self.signal.signal == signal.signal and repr(self.signal) == repr(
signal
)
elif qtpy.PYSIDE2:
# TODO: get this to work properly.
return bool(self.signal == signal)
raise qtrio.QTrioException() # pragma: no cover
def __eq__(self, other):
if type(other) != type(self):
return False
return self.is_from(signal=other.signal) and self.args == other.args |
|
FWIW I also use |
|
I honestly didn't know about this attribute. Found a reference in here: https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html. I think we can accept this PR to be more complete. |
…ignal Add pyqtBoundSignal.signal: str
No description provided.