本文整理汇总了Python中qgis.PyQt.QtCore.QEventLoop.exit方法的典型用法代码示例。如果您正苦于以下问题:Python QEventLoop.exit方法的具体用法?Python QEventLoop.exit怎么用?Python QEventLoop.exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtCore.QEventLoop
的用法示例。
在下文中一共展示了QEventLoop.exit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OpenlayersRenderer
# 需要导入模块: from qgis.PyQt.QtCore import QEventLoop [as 别名]
# 或者: from qgis.PyQt.QtCore.QEventLoop import exit [as 别名]
class OpenlayersRenderer(QgsMapLayerRenderer):
def __init__(self, layer, context, webPage, layerType):
""" Initialize the object. This function is still run in the GUI thread.
Should refrain from doing any heavy work.
"""
QgsMapLayerRenderer.__init__(self, layer.id())
self.context = context
self.controller = OpenlayersController(None,
context, webPage, layerType)
self.loop = None
def render(self):
""" do the rendering. This function is called in the worker thread """
debug("[WORKER THREAD] Calling request() asynchronously", 3)
QMetaObject.invokeMethod(self.controller, "request")
# setup a timer that checks whether the rendering has not been stopped
# in the meanwhile
timer = QTimer()
timer.setInterval(50)
timer.timeout.connect(self.onTimeout)
timer.start()
debug("[WORKER THREAD] Waiting for the async request to complete", 3)
self.loop = QEventLoop()
self.controller.finished.connect(self.loop.exit)
self.loop.exec_()
debug("[WORKER THREAD] Async request finished", 3)
painter = self.context.painter()
painter.drawImage(0, 0, self.controller.img)
return True
def onTimeout(self):
""" periodically check whether the rendering should not be stopped """
if self.context.renderingStopped():
debug("[WORKER THREAD] Cancelling rendering", 3)
self.loop.exit()