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


Python QtCore.QEventLoop类代码示例

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


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

示例1: MatrixDialog

class MatrixDialog(WindowModalDialog):

    def __init__(self, parent):
        super(MatrixDialog, self).__init__(parent)
        self.setWindowTitle(_("Trezor Matrix Recovery"))
        self.num = 9
        self.loop = QEventLoop()

        vbox = QVBoxLayout(self)
        vbox.addWidget(WWLabel(MATRIX_RECOVERY))

        grid = QGridLayout()
        grid.setSpacing(0)
        self.char_buttons = []
        for y in range(3):
            for x in range(3):
                button = QPushButton('?')
                button.clicked.connect(partial(self.process_key, ord('1') + y * 3 + x))
                grid.addWidget(button, 3 - y, x)
                self.char_buttons.append(button)
        vbox.addLayout(grid)

        self.backspace_button = QPushButton("<=")
        self.backspace_button.clicked.connect(partial(self.process_key, Qt.Key_Backspace))
        self.cancel_button = QPushButton(_("Cancel"))
        self.cancel_button.clicked.connect(partial(self.process_key, Qt.Key_Escape))
        buttons = Buttons(self.backspace_button, self.cancel_button)
        vbox.addSpacing(40)
        vbox.addLayout(buttons)
        self.refresh()
        self.show()

    def refresh(self):
        for y in range(3):
            self.char_buttons[3 * y + 1].setEnabled(self.num == 9)

    def is_valid(self, key):
        return key >= ord('1') and key <= ord('9')

    def process_key(self, key):
        self.data = None
        if key == Qt.Key_Backspace:
            self.data = '\010'
        elif key == Qt.Key_Escape:
            self.data = 'x'
        elif self.is_valid(key):
            self.char_buttons[key - ord('1')].setFocus()
            self.data = '%c' % key
        if self.data:
            self.loop.exit(0)

    def keyPressEvent(self, event):
        self.process_key(event.key())
        if not self.data:
            QDialog.keyPressEvent(self, event)

    def get_matrix(self, num):
        self.num = num
        self.refresh()
        self.loop.exec_()
开发者ID:faircoin,项目名称:electrumfair,代码行数:60,代码来源:qt.py

示例2: _processPendingEvents

def _processPendingEvents():
    """Process pending application events."""

    # Create an event loop to run in. Otherwise, we need to use the
    # QApplication main loop, which may already be running and therefore
    # unusable.
    qe = QEventLoop()

    # Create a single-shot timer. Could use QTimer.singleShot(),
    # but can't cancel this / disconnect it.
    timer = QTimer()
    timer.setSingleShot(True)
    timer.timeout.connect(qe.quit)
    timer.start(1)

    # Wait for an emitted signal.
    qe.exec_()

    # Clean up: don't allow the timer to call qe.quit after this
    # function exits, which would produce "interesting" behavior.
    timer.stop()
    # Stopping the timer may not cancel timeout signals in the
    # event queue. Disconnect the signal to be sure that loop
    # will never receive a timeout after the function exits.
    timer.timeout.disconnect(qe.quit)
开发者ID:gpa14,项目名称:enki,代码行数:25,代码来源:base.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:19joho66,项目名称:frescobaldi,代码行数:25,代码来源:qutil.py

示例4: AppDecorator

class AppDecorator(QObject):
    documentWasCreatedSignal = pyqtSignal(object)  # doc
    documentWindowWasCreatedSignal = pyqtSignal(object, object)  # doc, window
    def __init__(self,argv):
        self.qApp = QApplication(argv)
        super(AppDecorator, self).__init__()
        from cadnano.gui.views.preferences import Preferences
        self.prefs = Preferences()
        #icon = QIcon(ICON_PATH)
        #self.qApp.setWindowIcon(icon)


        self.document_controllers = set()  # Open documents
        self.active_document = None
        self.vh = {}  # Newly created VirtualHelix register here by idnum.
        self.vhi = {}
        self.partItem = None

        global decode
        global Document
        global DocumentController
        from cadnano.gui.views.pathview import pathstyles as styles
        styles.setFontMetrics()

    # def prefsClicked(self):
    #     self.prefs.showDialog()

    def exec_(self):
        if hasattr(self, 'qApp'):
            mainWindow = MainWindow()
            mainWindow.show()
            self.mainEventLoop = QEventLoop()
            self.mainEventLoop.exec_()
开发者ID:amylittleyang,项目名称:OtraCAD,代码行数:33,代码来源:appDecorator.py

示例5: send

 def send(params):
     url = self.formatUrl(endpoint, params)
     request = QNetworkRequest(url)
     headers['User-Agent'] = 'Divi QGIS Plugin/%s' % PLUGIN_VERSION
     QgsMessageLog.logMessage(str(headers), 'DIVI')
     for key, value in headers.items():
         request.setRawHeader(key.encode('utf-8'), value.encode('utf-8'))
     if method == 'delete':
         reply = manager.sendCustomRequest(request, 'DELETE'.encode('utf-8'), data)
     else:
         if not data:
             reply = getattr(manager, method)(request)
         elif isinstance(data, QHttpMultiPart) == True:
             reply = getattr(manager, method)(request, data)
         elif isinstance(data, str) == True:
             reply = getattr(manager, method)(request, data.encode('utf-8'))
     loop = QEventLoop()
     reply.uploadProgress.connect(self.uploadProgress)
     reply.downloadProgress.connect(self.downloadProgress)
     reply.metaDataChanged.connect(self.metaDataChanged)
     #reply.error.connect(self._error)
     reply.finished.connect(loop.exit)
     self.abort_sig.connect( reply.abort )
     loop.exec_()
     self.abort_sig.disconnect( reply.abort )
     return reply
开发者ID:gis-support,项目名称:DIVI-QGIS-Plugin,代码行数:26,代码来源:connector.py

示例6: f2

 def f2():
     future = ac.start(em2.g, lambda x: x, QThread.currentThread())
     # The doneSignal won't be processed without an event loop. A
     # thread pool doesn't create one, so make our own to run ``g``.
     qe = QEventLoop()
     future._signalInvoker.doneSignal.connect(qe.exit)
     qe.exec_()
开发者ID:gpa14,项目名称:enki,代码行数:7,代码来源:test_future.py

示例7: send_request

    def send_request(self, post=None, data={}):
        loop = QEventLoop()
        self.r.setUrl(self.url)
        if post:
            encoded_data = self._urlencode_post_data(data)
            pprint(encoded_data)
            self.reply_post = self.conn.post(self.r, encoded_data)
            self.reply_post.downloadProgress.connect(self.prepare_responce)

        else:
            self.reply = self.conn.get(self.r)
            self.reply.finished.connect(self.prepare_responce)
        # return \
        loop.exec()
开发者ID:blropb,项目名称:qt-test,代码行数:14,代码来源:browser.py

示例8: __init__

    def __init__(self, parent):
        super(MatrixDialog, self).__init__(parent)
        self.setWindowTitle(_("Trezor Matrix Recovery"))
        self.num = 9
        self.loop = QEventLoop()

        vbox = QVBoxLayout(self)
        vbox.addWidget(WWLabel(MATRIX_RECOVERY))

        grid = QGridLayout()
        grid.setSpacing(0)
        self.char_buttons = []
        for y in range(3):
            for x in range(3):
                button = QPushButton('?')
                button.clicked.connect(partial(self.process_key, ord('1') + y * 3 + x))
                grid.addWidget(button, 3 - y, x)
                self.char_buttons.append(button)
        vbox.addLayout(grid)

        self.backspace_button = QPushButton("<=")
        self.backspace_button.clicked.connect(partial(self.process_key, Qt.Key_Backspace))
        self.cancel_button = QPushButton(_("Cancel"))
        self.cancel_button.clicked.connect(partial(self.process_key, Qt.Key_Escape))
        buttons = Buttons(self.backspace_button, self.cancel_button)
        vbox.addSpacing(40)
        vbox.addLayout(buttons)
        self.refresh()
        self.show()
开发者ID:faircoin,项目名称:electrumfair,代码行数:29,代码来源:qt.py

示例9: run

 def run(self, installSignalHandlers=True):
     if self._ownApp:
         self._blockApp = self.qApp
     else:
         self._blockApp = QEventLoop()
     self.runReturn()
     self._blockApp.exec_()
开发者ID:joepie91,项目名称:aether-public,代码行数:7,代码来源:qt5reactor.py

示例10: exec_

 def exec_(self):
     if hasattr(self, 'qApp'):
         from initialization.ui_loader import UiLoader
         loader = UiLoader()
         loader.mainWindow.show()
         self.mainEventLoop = QEventLoop()
         self.mainEventLoop.exec_()
开发者ID:amylittleyang,项目名称:OtraCAD,代码行数:7,代码来源:appDecorator.py

示例11: waitForCallback

 def waitForCallback(self):
     assert self._state == CallbackFutureState.WAITING, 'Only callbacks being waited for may be skipped.'
     # Run events until the callback is invoked.
     self._qEventLoop = QEventLoop()
     self._qEventLoop.exec_()
     self._qEventLoop = None
     assert self._state == CallbackFutureState.COMPLETE
开发者ID:bjones1,项目名称:enki,代码行数:7,代码来源:preview_sync.py

示例12: __init__

    def __init__(self, parent):
        super(CharacterDialog, self).__init__(parent)
        self.setWindowTitle(_("KeepKey Seed Recovery"))
        self.character_pos = 0
        self.word_pos = 0
        self.loop = QEventLoop()
        self.word_help = QLabel()
        self.char_buttons = []

        vbox = QVBoxLayout(self)
        vbox.addWidget(WWLabel(CHARACTER_RECOVERY))
        hbox = QHBoxLayout()
        hbox.addWidget(self.word_help)
        for i in range(4):
            char_button = CharacterButton('*')
            char_button.setMaximumWidth(36)
            self.char_buttons.append(char_button)
            hbox.addWidget(char_button)
        self.accept_button = CharacterButton(_("Accept Word"))
        self.accept_button.clicked.connect(partial(self.process_key, 32))
        self.rejected.connect(partial(self.loop.exit, 1))
        hbox.addWidget(self.accept_button)
        hbox.addStretch(1)
        vbox.addLayout(hbox)

        self.finished_button = QPushButton(_("Seed Entered"))
        self.cancel_button = QPushButton(_("Cancel"))
        self.finished_button.clicked.connect(partial(self.process_key,
                                                     Qt.Key_Return))
        self.cancel_button.clicked.connect(self.rejected)
        buttons = Buttons(self.finished_button, self.cancel_button)
        vbox.addSpacing(40)
        vbox.addLayout(buttons)
        self.refresh()
        self.show()
开发者ID:vialectrum,项目名称:vialectrum,代码行数:35,代码来源:qt.py

示例13: __init__

 def __init__(self, file_info, parent=None):
     super(Ace, self).__init__(parent)
     self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     self.parent = parent
     self.file_info = file_info
     self.language = EditorHelper.lang_from_file_info(file_info)
     self.waitForReady = False
     self.loop = QEventLoop()
     
     settings = self.settings()
     settings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
     settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
     self.inspector = QWebInspector(self)
     showInspectorAction = QAction('showInspector', self)
     showInspectorAction.triggered.connect(self.showInspector)
     self.addAction(showInspectorAction)
     
     self.modificationChanged.connect(self.modification_changed)
     self.main_frame().javaScriptWindowObjectCleared.connect(self.__self_js)
     pckg, file_name = 'ace_editor', 'ace_editor.html'
     resource = pkg_resources.resource_string(pckg, file_name)
     html_template = str(resource, 'utf-8')
     #insert file content
     with open(self.file_info.absoluteFilePath(), 'r') as f:
         text = f.read()
         text = html.escape(text)
         html_template = html_template.replace('{{ content }}', text)
     base_url = QUrl.fromLocalFile(os.path.dirname(__file__))
     
     self.setHtml(html_template, base_url)
     self.modified = False
     
     if not self.waitForReady:
         self.loop.exec()
开发者ID:FlorianPerrot,项目名称:Mojuru,代码行数:34,代码来源:Ace.py

示例14: commRqData

    def commRqData(self, requestName, trCode, inquiry, screenNo):
        """
        키움서버에 TR 요청을 한다.

        조회요청메서드이며 빈번하게 조회요청시, 시세과부하 에러값 -200이 리턴된다.

        :param requestName: string - TR 요청명(사용자 정의)
        :param trCode: string
        :param inquiry: int - 조회(0: 조회, 2: 남은 데이터 이어서 요청)
        :param screenNo: string - 화면번호(4자리)
        """

        if not self.getConnectState():
            raise KiwoomConnectError()

        if not (isinstance(requestName, str)
                and isinstance(trCode, str)
                and isinstance(inquiry, int)
                and isinstance(screenNo, str)):

            raise ParameterTypeError()

        returnCode = self.dynamicCall("CommRqData(QString, QString, int, QString)", requestName, trCode, inquiry, screenNo)

        if returnCode != ReturnCode.OP_ERR_NONE:
            raise KiwoomProcessingError("commRqData(): " + ReturnCode.CAUSE[returnCode])

        # 루프 생성: receiveTrData() 메서드에서 루프를 종료시킨다.
        self.requestLoop = QEventLoop()
        self.requestLoop.exec_()
开发者ID:nsho77,项目名称:PyTrader,代码行数:30,代码来源:Kiwoom.py

示例15: terminate

    def terminate(self):
        # Only run this once.
        if self._isAlive:
            self._isAlive = False
            self._terminate()

            # Waiting for the thread or thread pool to shut down may have
            # placed completed jobs in this thread's queue. Process them now to
            # avoid any surprises (terminated `_AsyncAbstractController`_
            # instances still invoke callbacks, making it seem that the
            # terminate didn't fully terminate. It did, but still leaves g_
            # callbacks to be run in the event queue.)
            el = QEventLoop(self.parent())
            QTimer.singleShot(0, el.exit)
            el.exec_()

            # Delete the `QObject <http://doc.qt.io/qt-5/qobject.html>`_
            # underlying this class, which disconnects all signals.
            sip.delete(self)
开发者ID:freason,项目名称:enki,代码行数:19,代码来源:future.py


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