예제 #1
0
    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_()
예제 #2
0
 def progress_callback(finished):
     if task.cancelled:
         raise UserInterrupt()
     QMetaObject.invokeMethod(
         self, "setProgressValue", Qt.QueuedConnection,
         Q_ARG(float, 100 * finished)
     )
예제 #3
0
 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
예제 #4
0
    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
예제 #5
0
 def ondone(_):
     QMetaObject.invokeMethod(self, "__task_complete",
                              Qt.QueuedConnection, Q_ARG(object, task))
예제 #6
0
 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)
예제 #7
0
파일: addons.py 프로젝트: chrmorais/orange3
 def call(*args):
     args = [Q_ARG(atype, arg) for atype, arg in zip(sig, args)]
     return QMetaObject.invokeMethod(obj, name, conntype, *args)
예제 #8
0
 def callback_prediction(class_value):
     QMetaObject.invokeMethod(
         self, "update_model_prediction", Qt.QueuedConnection, Q_ARG(float, class_value))
예제 #9
0
 def callback_update(table):
     QMetaObject.invokeMethod(
         self, "update_view", Qt.QueuedConnection, Q_ARG(Orange.data.Table, table))
예제 #10
0
 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)
예제 #11
0
 def __call__(self, *args, **kwargs):
     safe_invoke(self.master, 'call',
                 Q_ARG(object, (self.instance, args, kwargs)))