Last active
May 5, 2016 09:09
-
-
Save cpascual/bcf16fc1820680ef768fb7962473d24b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import Qt | |
class Signaller(Qt.QObject): | |
signal = Qt.pyqtSignal() | |
class Base(object): | |
"""Base is not a QObject but provides a pyqtSignal signal member via | |
a Signaller hidden behind a property""" | |
def __init__(self): | |
self._signaller = Signaller() | |
@property | |
def signal(self): | |
return self._signaller.signal | |
class MyWidget(Qt.QLabel, Base): | |
"""3rd party widget which expects "signal" to be provided by Base""" | |
def __init__(self): | |
Qt.QLabel.__init__(self, 'testing signal') | |
Base.__init__(self) | |
# self.signal can now be used as expected | |
self.signal.connect(self.onSignal) | |
self.signal.emit() | |
def onSignal(self): | |
print "got signal!!!" | |
app=Qt.QApplication([]) | |
w = MyWidget() | |
w.show() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment