本文整理汇总了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_()
示例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_()
示例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()
示例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())
示例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")
示例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");
示例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_()
示例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
示例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
示例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
示例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
示例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
示例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)
示例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))
示例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
)