Skip to content

Instantly share code, notes, and snippets.

@smallevilbeast
Created December 19, 2013 03:18
Show Gist options
  • Save smallevilbeast/8033882 to your computer and use it in GitHub Desktop.
Save smallevilbeast/8033882 to your computer and use it in GitHub Desktop.
PostGui for PyQt
import functools
from PyQt5 import QtCore
class postGui(QtCore.QObject):
throughThread = QtCore.pyqtSignal(object, object)
def __init__(self, inclass=True):
super(postGui, self).__init__()
self.throughThread.connect(self.onSignalReceived)
self.inclass = inclass
def __call__(self, func):
self._func = func
@functools.wraps(func)
def objCall(*args, **kwargs):
self.emitSignal(args, kwargs)
return objCall
def emitSignal(self, args, kwargs):
self.throughThread.emit(args, kwargs)
def onSignalReceived(self, args, kwargs):
if self.inclass:
obj, args = args[0], args[1:]
self._func(obj, *args, **kwargs)
else:
self._func(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment