Skip to content

Instantly share code, notes, and snippets.

@smallevilbeast
Last active December 30, 2015 08:09
Show Gist options
  • Save smallevilbeast/7801180 to your computer and use it in GitHub Desktop.
Save smallevilbeast/7801180 to your computer and use it in GitHub Desktop.
post gui for PyQt
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