Last active
December 30, 2015 08:09
-
-
Save smallevilbeast/7801180 to your computer and use it in GitHub Desktop.
post gui for PyQt
This file contains 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
class postGui(QtCore.QObject): | |
throughThread = QtCore.pyqtSignal(object, object) | |
def __init__(self, func): | |
super(postGui, self).__init__() | |
self.throughThread.connect(self.onSignalReceived) | |
self._func = func | |
self._obj = None | |
def __get__(self, obj, cls=None): | |
self._obj = obj | |
return self.emitSignal | |
def emitSignal(self, *args, **kwargs): | |
self.throughThread.emit(args, kwargs) | |
def onSignalReceived(self, args, kwargs): | |
if self._obj is None: | |
return self._func(*args, **kwargs) | |
return self._func(self._obj, *args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment