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


Python QTimer.singleShot方法代码示例

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


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

示例1: test_err_windows

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def test_err_windows(qtbot, qapp, pre_text, post_text, expected, caplog):

    def err_window_check():
        w = qapp.activeModalWidget()
        assert w is not None
        try:
            qtbot.add_widget(w)
            if not utils.is_mac:
                assert w.windowTitle() == 'title'
            assert w.icon() == QMessageBox.Critical
            assert w.standardButtons() == QMessageBox.Ok
            assert w.text() == expected
        finally:
            w.close()

    QTimer.singleShot(10, err_window_check)

    with caplog.at_level(logging.ERROR):
        error.handle_fatal_exc(ValueError("exception"), 'title',
                               pre_text=pre_text, post_text=post_text,
                               no_err_windows=False) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:23,代码来源:test_error.py

示例2: __init__

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def __init__(self, req, errorstring, error, parent=None):
        """Constructor.

        Args:
            req: The QNetworkRequest associated with this reply.
            errorstring: The error string to print.
            error: The numerical error value.
            parent: The parent to pass to QNetworkReply.
        """
        super().__init__(parent)
        self.setRequest(req)
        self.setUrl(req.url())
        # We don't actually want to read anything, but we still need to open
        # the device to avoid getting a warning.
        self.setOpenMode(QIODevice.ReadOnly)
        self.setError(error, errorstring)
        QTimer.singleShot(0, lambda:
                          self.error.emit(error))  # type: ignore[attr-defined]
        QTimer.singleShot(0, lambda:
                          self.finished.emit())  # type: ignore[attr-defined] 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:22,代码来源:networkreply.py

示例3: load_items

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def load_items(self, items):
        if items:
            self._tab.before_load_started.emit(items[-1].url)

        stream, _data, user_data = tabhistory.serialize(items)
        qtutils.deserialize_stream(stream, self._history)
        for i, data in enumerate(user_data):
            self._history.itemAt(i).setUserData(data)
        cur_data = self._history.currentItem().userData()
        if cur_data is not None:
            if 'zoom' in cur_data:
                self._tab.zoom.set_factor(cur_data['zoom'])
            if ('scroll-pos' in cur_data and
                    self._tab.scroller.pos_px() == QPoint(0, 0)):
                QTimer.singleShot(0, functools.partial(
                    self._tab.scroller.to_point, cur_data['scroll-pos'])) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:18,代码来源:webkittab.py

示例4: _init_reply

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def _init_reply(self, reply):
        """Set a new reply and connect its signals.

        Args:
            reply: The QNetworkReply to handle.
        """
        self.done = False
        self.successful = False
        self._reply = reply
        reply.setReadBufferSize(16 * 1024 * 1024)  # 16 MB
        reply.downloadProgress.connect(self.stats.on_download_progress)
        reply.finished.connect(self._on_reply_finished)
        reply.error.connect(self._on_reply_error)
        reply.readyRead.connect(self._on_ready_read)
        reply.metaDataChanged.connect(self._on_meta_data_changed)
        self._retry_info = _RetryInfo(request=reply.request(),
                                      manager=reply.manager())
        if not self.fileobj:
            self._read_timer.start()
        # We could have got signals before we connected slots to them.
        # Here no signals are connected to the DownloadItem yet, so we use a
        # singleShot QTimer to emit them after they are connected.
        if reply.error() != QNetworkReply.NoError:
            QTimer.singleShot(0, lambda: self._die(reply.errorString())) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:26,代码来源:qtnetworkdownloads.py

示例5: update_geometry

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def update_geometry(obj):
    """Weird WORKAROUND for some weird PyQt bug (probably).

    This actually should be a method of DownloadView, but for some reason the
    rowsInserted/rowsRemoved signals don't get disconnected from this method
    when the DownloadView is deleted from Qt (e.g. by closing a window).

    Here we check if obj ("self") was deleted and just ignore the event if so.

    Original bug:   https://github.com/qutebrowser/qutebrowser/issues/167
    Workaround bug: https://github.com/qutebrowser/qutebrowser/issues/171
    """
    def _update_geometry():
        """Actually update the geometry if the object still exists."""
        if sip.isdeleted(obj):
            return
        obj.updateGeometry()

    # If we don't use a singleShot QTimer, the geometry isn't updated correctly
    # and won't include the new item.
    QTimer.singleShot(0, _update_geometry) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:23,代码来源:downloadview.py

示例6: _do_focus_workaround

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def _do_focus_workaround(self):
        """WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076."""
        if not self._focus_workaround:
            return

        assert self._widget is not None

        pass_modes = [usertypes.KeyMode.command,
                      usertypes.KeyMode.prompt,
                      usertypes.KeyMode.yesno]

        if modeman.instance(self._win_id).mode in pass_modes:
            return

        tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                    window=self._win_id)
        current_index = tabbed_browser.widget.currentIndex()
        try:
            widget_index = tabbed_browser.widget.indexOf(self._widget.parent())
        except RuntimeError:
            widget_index = -1
        if current_index == widget_index:
            QTimer.singleShot(0, self._widget.setFocus) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:25,代码来源:eventfilter.py

示例7: _load_window

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def _load_window(self, win):
        """Turn yaml data into windows."""
        window = mainwindow.MainWindow(geometry=win['geometry'],
                                       private=win.get('private', None))
        window.show()
        tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                    window=window.win_id)
        tab_to_focus = None
        for i, tab in enumerate(win['tabs']):
            new_tab = tabbed_browser.tabopen(background=False)
            self._load_tab(new_tab, tab)
            if tab.get('active', False):
                tab_to_focus = i
            if new_tab.data.pinned:
                tabbed_browser.widget.set_tab_pinned(new_tab,
                                                     new_tab.data.pinned)
        if tab_to_focus is not None:
            tabbed_browser.widget.setCurrentIndex(tab_to_focus)
        if win.get('active', False):
            QTimer.singleShot(0, tabbed_browser.widget.activateWindow) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:22,代码来源:sessions.py

示例8: _shutdown_2

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def _shutdown_2(self, status: int, is_restart: bool) -> None:
        """Second stage of shutdown."""
        log.destroy.debug("Stage 2 of shutting down...")

        # Tell everything to shut itself down
        self.shutting_down.emit()

        # Delete temp basedir
        if ((self._args.temp_basedir or self._args.temp_basedir_restarted) and
                not is_restart):
            atexit.register(shutil.rmtree, self._args.basedir,
                            ignore_errors=True)

        # Now we can hopefully quit without segfaults
        log.destroy.debug("Deferring QApplication::exit...")
        # We use a singleshot timer to exit here to minimize the likelihood of
        # segfaults.
        QTimer.singleShot(0, functools.partial(self._shutdown_3, status)) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:20,代码来源:quitter.py

示例9: add_saveable

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def add_saveable(self, name, save, changed=None, config_opt=None,
                     filename=None, dirty=False):
        """Add a new saveable.

        Args:
            name: The name to use.
            save: The function to call to save this saveable.
            changed: The signal emitted when this saveable changed.
            config_opt: An option deciding whether to auto-save or not.
            filename: The filename of the underlying file, so we can force
                      saving if it doesn't exist.
            dirty: Whether the saveable is already dirty.
        """
        if name in self.saveables:
            raise ValueError("Saveable {} already registered!".format(name))
        saveable = Saveable(name, save, changed, config_opt, filename)
        self.saveables[name] = saveable
        if dirty:
            saveable.mark_dirty()
            QTimer.singleShot(0, saveable.save) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:22,代码来源:savemanager.py

示例10: eventFilter

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def eventFilter(self, obj, event):
        def is_colors_dialog():
            return isinstance(
                obj, QDialog) and 'IDA Colors' in obj.windowTitle()

        if isinstance(event, QShowEvent) and is_colors_dialog():
            qApp.removeEventFilter(self)

            # Hide window and find &Import button
            obj.windowHandle().setOpacity(0)
            buttons = [widget for widget in obj.children() if isinstance(
                widget, QDialogButtonBox)][0]
            button = [widget for widget in buttons.buttons() if widget.text()
                      == '&Import'][0]

            with NativeHook(ask_file=self.ask_file_handler):
                button.click()

            QTimer.singleShot(0, lambda: obj.accept())
            return 1
        return 0 
开发者ID:zyantific,项目名称:IDASkins,代码行数:23,代码来源:clrapplier.py

示例11: Run

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def Run(self):
        items = ['From Address', 
                 'To Address',
                 'Email Subject',
                 'Thread Num',
                 'Verbose',
                 'Crazy Mode',
                 'Body']
        Attrs = self.GetAttrs()
        for item in items:
            if item not in Attrs:
                return
        
        InitVars(Attrs)
        if SMTP_addr:
            ver = "go"
            Launcher()
        else:
            threads_alive = [0]
        quit(0, 0)
        #loop = QEventLoop()
        #QTimer.singleShot(1000, loop.quit) 
开发者ID:Macr0phag3,项目名称:email_hack,代码行数:24,代码来源:email_hacker-GUI.py

示例12: __init__

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def __init__(self, icon: str, parent=None):
        super(Notification, self).__init__(parent)
        self.parent = parent
        self.theme = self.parent.theme
        self.setObjectName('notification')
        self.setContentsMargins(10, 10, 10, 10)
        self.setModal(True)
        self.setWindowFlags(Qt.Window | Qt.Dialog | Qt.FramelessWindowHint)
        self.setMinimumWidth(550)
        self.shown.connect(lambda: QTimer.singleShot(self.duration * 1000, self.close))
        self._title, self._message = '', ''
        self.buttons = []
        self.msgLabel = QLabel(self._message, self)
        self.msgLabel.setWordWrap(True)
        logo_label = QLabel('<img src="{}" width="82" />'.format(icon), self)
        logo_label.setFixedSize(82, 82)
        self.left_layout = QVBoxLayout()
        self.left_layout.addWidget(logo_label)
        layout = QHBoxLayout()
        layout.addStretch(1)
        layout.addLayout(self.left_layout)
        layout.addSpacing(10)
        layout.addWidget(self.msgLabel, Qt.AlignVCenter)
        layout.addStretch(1)
        self.setLayout(layout) 
开发者ID:ozmartian,项目名称:vidcutter,代码行数:27,代码来源:notifications.py

示例13: restart_launcher

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def restart_launcher(self, text):
        old_window = self.mainWindow
        self.mainWindow = TouchBaseWidget()
        layout = QVBoxLayout()
        layout.addStretch()

        lbl = QLabel(text)
        lbl.setWordWrap(True);
        lbl.setAlignment(Qt.AlignCenter)
        layout.addWidget(lbl)

        layout.addStretch()
        self.mainWindow.setLayout(layout)        
        self.mainWindow.show()
        old_window.close()
        # the 0 msec timer makes sure that the actual restart does
        # not happen before the message window has been displayed...
        QTimer.singleShot(0, self.do_restart_launcher) 
开发者ID:ftCommunity,项目名称:ftcommunity-TXT,代码行数:20,代码来源:display.py

示例14: remove_packages

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def remove_packages(self):
        """
        Work out which packages need to be removed and then kick off their
        removal.
        """
        dirs = [
            os.path.join(self.module_dir, d)
            for d in os.listdir(self.module_dir)
            if d.endswith("dist-info") or d.endswith("egg-info")
        ]
        self.pkg_dirs = {}
        for pkg in self.to_remove:
            for d in dirs:
                # Assets on the filesystem use a normalised package name.
                pkg_name = pkg.replace("-", "_").lower()
                if os.path.basename(d).lower().startswith(pkg_name + "-"):
                    self.pkg_dirs[pkg] = d
        if self.pkg_dirs:
            # If there are packages to remove, schedule removal.
            QTimer.singleShot(2, self.remove_package) 
开发者ID:mu-editor,项目名称:mu,代码行数:22,代码来源:dialogs.py

示例15: disconnectedStateEntered

# 需要导入模块: from PyQt5.QtCore import QTimer [as 别名]
# 或者: from PyQt5.QtCore.QTimer import singleShot [as 别名]
def disconnectedStateEntered(self):
        # print(util.whoami())
        if( self.getConnectState() == 0 ):
            self.commConnect()
            QTimer.singleShot(90000, self.sigTryConnect)
            pass
        else:
            self.sigConnected.emit() 
开发者ID:coreanq,项目名称:kw_condition,代码行数:10,代码来源:main.py


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