当前位置: 首页>>代码示例>>Python>>正文


Python QMetaObject.invokeMethod方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QMetaObject.invokeMethod方法的典型用法代码示例。如果您正苦于以下问题:Python QMetaObject.invokeMethod方法的具体用法?Python QMetaObject.invokeMethod怎么用?Python QMetaObject.invokeMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QMetaObject的用法示例。


在下文中一共展示了QMetaObject.invokeMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
    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 isinstance(self.task.thread(), _TaskDepotThread)
        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.
        # TODO: If the task encounters an critical error it might not emit
        # these signals and this Runnable will never complete.
        self.task.finished.connect(self.eventLoop.quit)
        self.task.cancelled.connect(self.eventLoop.quit)
        self.eventLoop.exec_()
开发者ID:CHANAYA,项目名称:orange3,代码行数:29,代码来源:concurrent.py

示例2: run

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
    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_()
开发者ID:675801717,项目名称:orange3,代码行数:28,代码来源:concurrent.py

示例3: _show_backup_decision

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
    def _show_backup_decision(self, error=None):
        text = '<p>{0}</p><p>{1}</p>'.format(
            self.BACKUP_INTRO_TEXT if error is None else error,
            self.BACKUP_PROMPT_TEXT,
        )

        dialog = QMessageBox(
            QMessageBox.Question if error is None else QMessageBox.Critical,
            self.BACKUP_DIALOG_CAPTION if error is None else self.BACKUP_DIALOG_ERROR_CAPTION,
            text,
        )

        revert_button = dialog.addButton(self.REVERT_BACKUP_BUTTON_TEXT, QMessageBox.AcceptRole)
        delete_button = dialog.addButton(self.DELETE_BACKUP_BUTTON_TEXT, QMessageBox.DestructiveRole)
        examine_button = dialog.addButton(self.EXAMINE_BACKUP_BUTTON_TEXT, QMessageBox.ActionRole)
        dialog.addButton(self.QUIT_BUTTON_TEXT, QMessageBox.RejectRole)

        dialog.exec()
        clicked_button = dialog.clickedButton()

        if clicked_button == examine_button:
            QMetaObject.invokeMethod(self, '_examine_backup', Qt.QueuedConnection)
        elif clicked_button == revert_button:
            self._progress_dialog = QProgressDialog(None)
            self._progress_dialog.setLabelText(self.REVERT_BACKUP_PROGRESS_TEXT)
            self._progress_dialog.setCancelButton(None)
            self._progress_dialog.setRange(0, 0)
            self._progress_dialog.forceShow()

            self.request_revert_backup.emit()
        elif clicked_button == delete_button:
            self.request_delete_backup.emit()
        else:
            self.quit()
开发者ID:goc9000,项目名称:baon,代码行数:36,代码来源:BAONQtApplication.py

示例4: run

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 def run(self):
     ret = None
     try:
         if self.object is not None and self.method is not None:
             # TODO Get return value.
             QMetaObject.invokeMethod(self.object, self.method, self.connection)
     except Exception, e:
         self.error.emit(e, traceback.format_exc())
开发者ID:fgcartographix,项目名称:qgis-cartodb,代码行数:10,代码来源:CartoDBPluginWorker.py

示例5: done

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 def done(self):
     self.timer.stop()
     self.popup.hide()
     self.editor.setFocus()
     item = self.popup.currentItem()
     if item:
         self.editor.setText(item.text(0))
         QMetaObject.invokeMethod(self.editor, "returnPressed")
开发者ID:Answeror,项目名称:memoit,代码行数:10,代码来源:suggest.py

示例6: doneCompletion

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 def doneCompletion(self):
     self.timer.stop()
     self.ui.popup.hide()
     self.ui.editor.setFocus()
     item = self.ui.popup.currentItem()
     if item != None:
         self.currentItem = self.ui.popup.currentItem().data(0,0)
         self.ui.editor.setText(item.text(self.textplacetoeditor))
         QMetaObject.invokeMethod(self.ui.editor, "returnPressed");
开发者ID:mape90,项目名称:VetApp,代码行数:11,代码来源:searchlineedit.py

示例7: run

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 def run(self):
     self.eventLoop = QEventLoop()
     self.eventLoop.processEvents()
     QObject.connect(self._call, SIGNAL("finished(QString)"),
                     lambda str: self.eventLoop.quit())
     QMetaObject.invokeMethod(self._call, "moveToAndInit",
                              Qt.QueuedConnection,
                              Q_ARG("PyQt_PyObject",
                                    QThread.currentThread()))
     self.eventLoop.processEvents()
     self.eventLoop.exec_()
开发者ID:pauloortins,项目名称:Computer-Vision-Classes---UFBA,代码行数:13,代码来源:OWConcurrent.py

示例8: run

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 def run(self):
     try:
         result = self.func(*(self.args), **(self.kwargs))
     except Exception as e:
         logger.exception("deferToThread caught exception: %r", e)
         QMetaObject.invokeMethod(DeferCallThread.mainThreadStub, "_slot_errback", Qt.QueuedConnection,
                 Q_ARG("PyQt_PyObject", self.done), Q_ARG("PyQt_PyObject", e))
     else:
         QMetaObject.invokeMethod(DeferCallThread.mainThreadStub, "_slot_callback", Qt.QueuedConnection,
                 Q_ARG("PyQt_PyObject", self.done), Q_ARG("PyQt_PyObject", result))
     finally:
         del self.func, self.done, self.args, self.kwargs
开发者ID:OSUser,项目名称:eventlet-pyqt,代码行数:14,代码来源:eventlet.py

示例9: func

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
        def func():
            try:
                QMetaObject.invokeMethod(self, "_on_start", Qt.QueuedConnection)
                if allow_partial_results:
                    kwargs['should_break'] = should_break
                res = method(self, *args, on_progress=on_progress, **kwargs)
            except StopExecution:
                res = None

            QMetaObject.invokeMethod(self, "_on_result", Qt.QueuedConnection,
                                     Q_ARG(object, res))
            self.running = False
开发者ID:nikicc,项目名称:orange3-text,代码行数:14,代码来源:concurrent.py

示例10: shutdown

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
    def shutdown(self, wait=True):
        """
        Shutdown the executor and free all resources. If `wait` is True then
        wait until all pending futures are executed or cancelled.
        """
        if self._depot_thread is not None:
            QMetaObject.invokeMethod(
                self._depot_thread, "quit", Qt.AutoConnection)

        if wait:
            self._threadPool.waitForDone()
            if self._depot_thread:
                self._depot_thread.wait()
                self._depot_thread = None
开发者ID:CHANAYA,项目名称:orange3,代码行数:16,代码来源:concurrent.py

示例11: handleRequest

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
    def handleRequest(self):
        request = WebServerRequest(self)
        response = WebServerResponse(self)

        for server in servers:
            # verify which server this request is for
            if self.server == server.httpd:
                connectionType = Qt.BlockingQueuedConnection
                if QThread.currentThread() == server.thread():
                    connectionType = Qt.DirectConnection

                QMetaObject.invokeMethod(server, 'newRequest', connectionType,
                                         Q_ARG(WebServerRequest, request),
                                         Q_ARG(WebServerResponse, response))
                break
开发者ID:abacusadvertising,项目名称:pyphantomjs,代码行数:17,代码来源:webserver.py

示例12: fetchFiles

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
  def fetchFiles(self, urls, renderContext):
    downloader = Downloader(None, self.maxConnections, self.cacheExpiry, self.userAgent)
    downloader.moveToThread(QgsApplication.instance().thread())
    downloader.timer.moveToThread(QgsApplication.instance().thread())

    self.logT("TileLayer.fetchFiles() starts")
    # create a QEventLoop object that belongs to the current worker thread
    eventLoop = QEventLoop()
    downloader.allRepliesFinished.connect(eventLoop.quit)
    if self.iface:
      # for download progress
      downloader.replyFinished.connect(self.networkReplyFinished)
      self.downloader = downloader

    # create a timer to watch whether rendering is stopped
    watchTimer = QTimer()
    watchTimer.timeout.connect(eventLoop.quit)

    # fetch files
    QMetaObject.invokeMethod(self.downloader, "fetchFilesAsync", Qt.QueuedConnection, Q_ARG(list, urls), Q_ARG(int, self.plugin.downloadTimeout))

    # wait for the fetch to finish
    tick = 0
    interval = 500
    timeoutTick = self.plugin.downloadTimeout * 1000 / interval
    watchTimer.start(interval)
    while tick < timeoutTick:
      # run event loop for 0.5 seconds at maximum
      eventLoop.exec_()
      if downloader.unfinishedCount() == 0 or renderContext.renderingStopped():
        break
      tick += 1
    watchTimer.stop()

    if downloader.unfinishedCount() > 0:
      downloader.abort(False)
      if tick == timeoutTick:
        downloader.errorStatus = Downloader.TIMEOUT_ERROR
        self.log("fetchFiles(): timeout")

    # watchTimer.timeout.disconnect(eventLoop.quit)
    # downloader.allRepliesFinished.disconnect(eventLoop.quit)

    self.logT("TileLayer.fetchFiles() ends")
    return downloader.fetchedFiles
开发者ID:gueguenster,项目名称:TileLayerPlugin,代码行数:47,代码来源:tilelayer.py

示例13: wrapper

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 def wrapper(obj, *args):
     # XXX: support kwargs?
     qargs = [Q_ARG(t, v) for t, v in zip(self.args, args)]
     invoke_args = [obj._instance, self.name]
     invoke_args.append(Qt.DirectConnection)
     rtype = self.returnType
     if rtype:
         invoke_args.append(Q_RETURN_ARG(rtype))
     invoke_args.extend(qargs)
     try:
         result = QMetaObject.invokeMethod(*invoke_args)
         error_msg = str(qApp.property("MIKRO_EXCEPTION").toString())
         if error_msg:
             # clear message
             qApp.setProperty("MIKRO_EXCEPTION", QVariant())
             raise Error(error_msg)
     except RuntimeError, e:
         raise TypeError, \
             "%s.%s(%r) call failed: %s" % (obj, self.name, args, e)
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:21,代码来源:mikro.py

示例14: on_progress

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 def on_progress(i):
     if not self.running and not allow_partial_results:
         raise StopExecution
     QMetaObject.invokeMethod(self, "_on_progress", Qt.QueuedConnection,  Q_ARG(float, i))
开发者ID:nikicc,项目名称:orange3-text,代码行数:6,代码来源:concurrent.py

示例15: __call__

# 需要导入模块: from PyQt4.QtCore import QMetaObject [as 别名]
# 或者: from PyQt4.QtCore.QMetaObject import invokeMethod [as 别名]
 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
     )
开发者ID:CHANAYA,项目名称:orange3,代码行数:8,代码来源:concurrent.py


注:本文中的PyQt4.QtCore.QMetaObject.invokeMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。