def run(self): """ Reimplemented from `QRunnable.run` """ self.eventLoop = QEventLoop() self.eventLoop.processEvents() # Move the task to the current thread so it's events, signals, slots # are triggered from this thread. assert self.task.thread() is _TaskDepotThread.instance() QMetaObject.invokeMethod( self.task.thread(), "transfer", Qt.BlockingQueuedConnection, Q_ARG(object, self.task), Q_ARG(object, QThread.currentThread()), ) self.eventLoop.processEvents() # Schedule task.run from the event loop. self.task.start() # Quit the loop and exit when task finishes or is cancelled. self.task.finished.connect(self.eventLoop.quit) self.task.cancelled.connect(self.eventLoop.quit) self.eventLoop.exec_()
def progress_callback(finished): if task.cancelled: raise UserInterrupt() QMetaObject.invokeMethod( self, "setProgressValue", Qt.QueuedConnection, Q_ARG(float, 100 * finished) )
def callback(progress): nonlocal task # update progress bar QMetaObject.invokeMethod( self, "set_progress_value", Qt.QueuedConnection, Q_ARG(int, progress)) if task.canceled: return True return False
def run(self, *args, **kwargs): if self.im_func.start_callback and self.im_self: safe_invoke(self.im_self, self.im_func.start_callback) if self.im_self: args = (self.im_self, ) + args try: result = self.im_func.method(*args, **kwargs) except StopExecution: result = None if self.im_func.finish_callback and self.im_self: safe_invoke(self.im_self, self.im_func.finish_callback, Q_ARG(object, result)) self.running = False
def ondone(_): QMetaObject.invokeMethod(self, "__task_complete", Qt.QueuedConnection, Q_ARG(object, task))
def __call__(self, *args): args = [Q_ARG(atype, arg) for atype, arg in zip(self.arg_types, args)] return QMetaObject.invokeMethod(self.obj, self.method, self.conntype, *args)
def call(*args): args = [Q_ARG(atype, arg) for atype, arg in zip(sig, args)] return QMetaObject.invokeMethod(obj, name, conntype, *args)
def callback_prediction(class_value): QMetaObject.invokeMethod( self, "update_model_prediction", Qt.QueuedConnection, Q_ARG(float, class_value))
def callback_update(table): QMetaObject.invokeMethod( self, "update_view", Qt.QueuedConnection, Q_ARG(Orange.data.Table, table))
def __call__(self, *args): args = [Q_ARG(atype, arg) for atype, arg in zip(self.arg_types, args)] QMetaObject.invokeMethod(self.obj, self.method, Qt.QueuedConnection, *args)
def __call__(self, *args, **kwargs): safe_invoke(self.master, 'call', Q_ARG(object, (self.instance, args, kwargs)))