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


Python QtCore.QEventLoop类代码示例

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


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

示例1: getUserTables

    def getUserTables(self, page=1, per_page=20, shared="yes", returnDict=True):
        self.returnDict = returnDict
        payload = {
            "tag_name": "",
            "q": "",
            "page": page,
            "type": "",
            "exclude_shared": "false",
            "per_page": per_page,
            "tags": "",
            "shared": shared,
            "locked": "false",
            "only_liked": "false",
            "order": "name",
            "types": "table",
        }
        url = QUrl(self.apiUrl + "viz?api_key={}&{}".format(self.apiKey, urllib.urlencode(payload)))
        request = self._getRequest(url)

        reply = self.manager.get(request)
        loop = QEventLoop()
        reply.downloadProgress.connect(self.progressCB)
        reply.error.connect(self._error)
        reply.finished.connect(loop.exit)
        loop.exec_()
开发者ID:mapping,项目名称:qgis-cartodb,代码行数:25,代码来源:cartodbapi.py

示例2: run

    def run(self):
        time = QTime()
        eventLoop = QEventLoop()

        self.m_bStop = False

#        log.debug("Запускаем поток")
        #if not self.initThread():
            #return
        while not self.m_bStop:
            self.m_nTactCounter += 1 # Добавить обнуление при переполнении

            time.start()
            eventLoop.processEvents()

            if not self.workThread():
                self.m_bStop = True
                return
            workTime = time.elapsed()
            if 0 <= workTime < self.m_nTact:
                self.msleep(self.m_nTact - workTime)
            else:
                self.msleep(0)

        eventLoop.processEvents()

        self.exitThread()
开发者ID:filin86,项目名称:CanLogger,代码行数:27,代码来源:timedthread.py

示例3: waitForSignal

def waitForSignal(signal, message="", timeout=0):
    """Waits (max timeout msecs if given) for a signal to be emitted.
    
    It the waiting lasts more than 2 seconds, a progress dialog is displayed
    with the message.
    
    Returns True if the signal was emitted.
    Return False if the wait timed out or the dialog was canceled by the user.
    
    """
    loop = QEventLoop()
    dlg = QProgressDialog(minimum=0, maximum=0, labelText=message)
    dlg.setWindowTitle(appinfo.appname)
    dlg.setWindowModality(Qt.ApplicationModal)
    QTimer.singleShot(2000, dlg.show)
    dlg.canceled.connect(loop.quit)
    if timeout:
        QTimer.singleShot(timeout, dlg.cancel)
    stop = lambda: loop.quit()
    signal.connect(stop)
    loop.exec_()
    signal.disconnect(stop)
    dlg.hide()
    dlg.deleteLater()
    return not dlg.wasCanceled()
开发者ID:EdwardBetts,项目名称:frescobaldi,代码行数:25,代码来源:qutil.py

示例4: getUserTables

    def getUserTables(self, page=1, per_page=20, shared='yes', returnDict=True):
        self.returnDict = returnDict
        payload = {
            'tag_name': '',
            'q': '',
            'page': page,
            'type': '',
            'exclude_shared': 'false',
            'per_page': per_page,
            'tags': '',
            'shared': shared,
            'locked': 'false',
            'only_liked': 'false',
            'order': 'name',
            'types': 'table'
        }
        url = QUrl(self.apiUrl + "viz?api_key={}&{}".format(self.apiKey, urllib.urlencode(payload)))
        request = self._getRequest(url)

        reply = self.manager.get(request)
        loop = QEventLoop()
        reply.downloadProgress.connect(self.progressCB)
        reply.error.connect(self._error)
        reply.finished.connect(loop.exit)
        loop.exec_()
开发者ID:matthewblain,项目名称:qgis-cartodb,代码行数:25,代码来源:cartodbapi.py

示例5: OeQ_wait_for_file

def OeQ_wait_for_file(filepath,timeout=10000):
    """Block loop until signal emitted, or timeout (ms) elapses."""
    from PyQt4.QtCore import QEventLoop,QTimer
    from os.path import isfile
    import platform
    import os
    if platform.system() == 'Darwin':
        return True
    if isfile(filepath):
        return True
    loop = QEventLoop()
    timer=QTimer()
    file_result = [True]
    #
    def check_file(testpath):

        if isfile(testpath):
            timer.stop()
            loop.quit()
    #
    timer.timeout.connect(lambda: check_file(filepath))
    timer.setSingleShot(False)
    timer.start(500)
    #
    def timed_out(file_result_flag):
        file_result_flag[0]=False
        loop.quit()
    #
    if timeout >500:
        timer.singleShot(timeout,lambda: timed_out(file_result))
    loop.exec_()
    return file_result[0]
开发者ID:uvchik,项目名称:Open_eQuarter,代码行数:32,代码来源:oeq_global.py

示例6: OeQ_wait_for_renderer

def OeQ_wait_for_renderer(timeout=10000):
    """Block loop until signal emitted, or timeout (ms) elapses."""
    from PyQt4.QtCore import QEventLoop,QTimer
    #print 'wait for renderer...',
    # function call if action timed out
    def timed_out(render_result_flag):
        render_result_flag[0]=False
        loop.quit()
    #define loop
    loop = QEventLoop()
    #define Timer
    timer=QTimer()
    #define render_result
    render_result = [True]

    OeQ_wait(2)

    #check wether Canvas is drawing
    if iface.mapCanvas().isDrawing():
        #connect mapCanvasRefreshed and renderComplete events to quit loop
        iface.mapCanvas().renderComplete.connect(loop.quit)
        iface.mapCanvas().mapCanvasRefreshed.connect(loop.quit)
        # if a timeout is defined and other than 0
        if bool(timeout):
            # start timer
            timer.singleShot(timeout,lambda: timed_out(render_result))
        #and jump into the loop
        loop.exec_()
        #disconnect after loop has quit
        iface.mapCanvas().mapCanvasRefreshed.disconnect(loop.quit)
        iface.mapCanvas().renderComplete.disconnect(loop.quit)
    #print 'Done'
    return render_result[0]
开发者ID:uvchik,项目名称:Open_eQuarter,代码行数:33,代码来源:oeq_global.py

示例7: __sync_request

    def __sync_request(self, url):
        _url = QUrl(url)
        _request = QNetworkRequest(_url)
        self.__replies.append(_request)

        QgsNetworkAccessManager.instance().sslErrors.connect(self.__supress_ssl_errors)

        _reply = QgsNetworkAccessManager.instance().get(_request)

        # wait
        loop = QEventLoop()
        _reply.finished.connect(loop.quit)
        loop.exec_()
        _reply.finished.disconnect(loop.quit)
        QgsNetworkAccessManager.instance().sslErrors.disconnect(self.__supress_ssl_errors)
        loop = None

        error = _reply.error()
        if error != QNetworkReply.NoError:
            raise Exception(error)

        result_code = _reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)

        result = _reply.readAll()
        self.__replies.append(_reply)
        _reply.deleteLater()

        if result_code in [301, 302, 307]:
            redirect_url = _reply.attribute(QNetworkRequest.RedirectionTargetAttribute)
            return self.__sync_request(redirect_url)
        else:
            return result
开发者ID:MatzFan,项目名称:quickmapservices,代码行数:32,代码来源:extra_sources.py

示例8: get

    def get(self, url=None, script=None, key=None):
        """Load given url in webkit and return html when loaded
        """
        self.base_url = self.base_url or url # set base URL if not set
        html = self.cache.get(key)
        if html:
            if self.debug: print 'load cache', key 
            self.setHtml(html, QUrl(self.base_url))
        elif url:
            self.load(QUrl(url))
        elif script:
            self.js(script)

        loop = QEventLoop()
        timer = QTimer()
        timer.setSingleShot(True)
        timer.timeout.connect(loop.quit)
        self.loadFinished.connect(loop.quit)
        timer.start(self.timeout * 1000)
        loop.exec_() # delay here until download finished or timeout
    
        if timer.isActive():
            # downloaded successfully
            timer.stop()
            html = self.current_html()
            if key:
                self.cache[key] = html
            self.inject_jquery()
        else:
            # didn't download in time
            print 'Download timeout'
            html = ''
        return html
开发者ID:gerrich,项目名称:qtbot,代码行数:33,代码来源:qt_framework.py

示例9: download

    def download(self, sql):
        apiUrl = "http://{}.cartodb.com/api/v2/sql?api_key={}&format=spatialite&q={}".format(
            self.cartodbUser, self.apiKey, sql
        )
        url = QUrl(apiUrl)
        request = self._getRequest(url)

        def finished(reply):
            tempdir = tempfile.tempdir
            if tempdir is None:
                tempdir = tempfile.mkdtemp()

            tf = tempfile.NamedTemporaryFile(delete=False)
            sqlite = QFile(tf.name)
            tf.close()
            if sqlite.open(QIODevice.WriteOnly):
                sqlite.write(reply.readAll())
                sqlite.close()
                self.fetchContent.emit(tf.name)
            else:
                self.error.emit("Error saving downloaded file")

        manager = QNetworkAccessManager()
        manager.finished.connect(finished)

        reply = manager.get(request)
        loop = QEventLoop()
        reply.downloadProgress.connect(self.progressCB)
        reply.error.connect(self._error)
        reply.finished.connect(loop.exit)
        loop.exec_()
开发者ID:mapping,项目名称:qgis-cartodb,代码行数:31,代码来源:cartodbapi.py

示例10: CartoDBLayerWorker

class CartoDBLayerWorker(QObject):
    finished = pyqtSignal(CartoDBLayer)
    error = pyqtSignal(Exception, basestring)

    def __init__(self, iface, tableName, owner=None, dlg=None, sql=None, filterByExtent=False, readonly=False, multiuser=False):
        QObject.__init__(self)
        self.iface = iface
        self.owner = owner
        self.tableName = tableName
        self.readonly = readonly
        self.multiuser = multiuser
        self.dlg = dlg
        self.sql = sql
        self.filterByExtent = filterByExtent
        self.loop = None

    def load(self):
        worker = CartoDBPluginWorker(self, 'loadLayer')
        worker.error.connect(self.workerError)
        self.loop = QEventLoop()
        worker.finished.connect(self.workerFinished)
        worker.start()
        self.loop.exec_()

    @pyqtSlot(str)
    def _loadData(self, spatiaLite):
        layer = CartoDBLayer(self.iface, self.tableName, self.dlg.currentUser, self.dlg.currentApiKey,
                             self.owner, self.sql, spatiaLite=spatiaLite, readonly=self.readonly, multiuser=self.multiuser)
        self.finished.emit(layer)

    @pyqtSlot()
    def loadLayer(self):
        if self.sql is None:
            sql = 'SELECT * FROM ' + ((self.owner + '.') if self.owner != self.dlg.currentUser else '') + self.tableName
            if self.filterByExtent:
                extent = self.iface.mapCanvas().extent()
                sql = sql + " WHERE ST_Intersects(ST_GeometryFromText('{}', 4326), the_geom)".format(extent.asWktPolygon())
        else:
            sql = self.sql

        cartoDBApi = CartoDBApi(self.dlg.currentUser, self.dlg.currentApiKey)
        cartoDBApi.fetchContent.connect(self._loadData)
        cartoDBApi.download(sql)
        # cartoDBApi.getDataFromTable(sql, False)
        # geoJSON = self._loadData()

    """
    On worker has finished
    """
    def workerFinished(self, ret):
        QgsMessageLog.logMessage('Task finished:\n' + str(ret), 'CartoDB Plugin', QgsMessageLog.INFO)
        self.loop.exit()

    """
    On worker error
    """
    def workerError(self, e, exception_string):
        QgsMessageLog.logMessage('Worker thread raised an exception: {} - {}\n'.format(exception_string, str(e)),
                                 'CartoDB Plugin', QgsMessageLog.CRITICAL)
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:59,代码来源:CartoDBLayer.py

示例11: request

 def request(self, url):
     ''' prepare the request and return the result of the reply
     '''
     request = QNetworkRequest(QUrl(url))
     reply = self.manager.get(request)
     reply.deleteLater()
     evloop = QEventLoop()
     reply.finished.connect(evloop.quit)
     evloop.exec_(QEventLoop.ExcludeUserInputEvents)
     return unicode(reply.readAll())
开发者ID:jeremyk6,项目名称:gban,代码行数:10,代码来源:gban.py

示例12: updateLayerInMap

    def updateLayerInMap(self, mapId, layer, returnDict=True):
        self.returnDict = returnDict
        url = QUrl(self.apiUrl + "maps/{}/layers/{}?api_key={}".format(mapId, layer["id"], self.apiKey))
        request = self._getRequest(url)

        reply = self.manager.put(request, json.dumps(layer))
        loop = QEventLoop()
        reply.downloadProgress.connect(self.progressCB)
        reply.error.connect(self._error)
        reply.finished.connect(loop.exit)
        loop.exec_()
开发者ID:mapping,项目名称:qgis-cartodb,代码行数:11,代码来源:cartodbapi.py

示例13: getLayersMap

    def getLayersMap(self, mapId, returnDict=True):
        self.returnDict = returnDict
        url = QUrl(self.apiUrl + "maps/{}/layers?api_key={}".format(mapId, self.apiKey))
        request = self._getRequest(url)

        reply = self.manager.get(request)
        loop = QEventLoop()
        reply.downloadProgress.connect(self.progressCB)
        reply.error.connect(self._error)
        reply.finished.connect(loop.exit)
        loop.exec_()
开发者ID:mapping,项目名称:qgis-cartodb,代码行数:11,代码来源:cartodbapi.py

示例14: _wait_signal

def _wait_signal(signal, timeout=None):
    """Block loop until signal emitted, or timeout (ms) elapses."""
    # http://jdreaver.com/posts/2014-07-03-waiting-for-signals-pyside-pyqt.html
    loop = QEventLoop()
    signal.connect(loop.quit)

    yield

    if timeout is not None:
        QTimer.singleShot(timeout, loop.quit)
    loop.exec_()
开发者ID:ablot,项目名称:phy,代码行数:11,代码来源:qt.py

示例15: getUserDetails

    def getUserDetails(self, returnDict=True):
        self.returnDict = returnDict
        url = QUrl(self.apiUrl + "users/{}/?api_key={}".format(self.cartodbUser, self.apiKey))
        request = self._getRequest(url)

        reply = self.manager.get(request)
        loop = QEventLoop()
        reply.downloadProgress.connect(self.progressCB)
        reply.error.connect(self._error)
        reply.finished.connect(loop.exit)
        loop.exec_()
开发者ID:mapping,项目名称:qgis-cartodb,代码行数:11,代码来源:cartodbapi.py


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