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


Python QTimer.singleShot方法代码示例

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


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

示例1: refresh

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
 def refresh(self):
     """load this game and this player. Keep parameter list identical with
     ExplainView"""
     if not self.game:
         # keep scores of previous game on display
         return
     if self.scoreModel:
         expandGroups = [self.viewLeft.isExpanded(self.scoreModel.index(x, 0, QModelIndex())) for x in range(4)]
     else:
         expandGroups = [True, False, True, True]
     gameid = str(self.game.seed or self.game.gameid)
     if self.game.finished():
         title = m18n("Final scores for game <numid>%1</numid>", gameid)
     else:
         title = m18n("Scores for game <numid>%1</numid>", gameid)
     decorateWindow(self, title)
     self.ruleTree.rulesets = list([self.game.ruleset])
     self.scoreModel = ScoreModel(self)
     if Debug.modelTest:
         self.scoreModelTest = ModelTest(self.scoreModel, self)
     for view in [self.viewLeft, self.viewRight]:
         view.setModel(self.scoreModel)
         header = view.header()
         header.setStretchLastSection(False)
         view.setAlternatingRowColors(True)
     if usingQt5:
         self.viewRight.header().setSectionResizeMode(QHeaderView.Fixed)
     else:
         self.viewRight.header().setResizeMode(QHeaderView.Fixed)
     for col in range(self.viewLeft.header().count()):
         self.viewLeft.header().setSectionHidden(col, col > 0)
         self.viewRight.header().setSectionHidden(col, col == 0)
     self.scoreLayout.setStretch(1, 100)
     self.scoreLayout.setSpacing(0)
     self.viewLeft.setFrameStyle(QFrame.NoFrame)
     self.viewRight.setFrameStyle(QFrame.NoFrame)
     self.viewLeft.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     for master, slave in ((self.viewRight, self.viewLeft), (self.viewLeft, self.viewRight)):
         master.expanded.connect(slave.expand)
         master.collapsed.connect(slave.collapse)
         master.verticalScrollBar().valueChanged.connect(slave.verticalScrollBar().setValue)
     for row, expand in enumerate(expandGroups):
         self.viewLeft.setExpanded(self.scoreModel.index(row, 0, QModelIndex()), expand)
     self.viewLeft.resizeColumnToContents(0)
     self.viewRight.setColWidth()
     # we need a timer since the scrollbar is not yet visible
     QTimer.singleShot(0, self.scrollRight)
开发者ID:KDE,项目名称:kajongg,代码行数:49,代码来源:scoringdialog.py

示例2: openFile

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
def openFile(pdf):
    """ Open the specified PDF document """

    global _file

    c = KApplication.dcopClient()
    kpdf = DCOPApp(c.appId(), c).kpdf

    # When LilyPond writes a PDF, it first deletes the old one.
    # So the new PDF gets a different inode number, which causes
    # KPDF to sometimes loose the 'watch' on the file.
    # So we call KPDF to open the file, and remember the page number
    # displayed ourselves, because KPDF also seems to forget the scroll
    # position due to LilyPond deleting the old PDF first.
    # It would be best that either KPDF is fixed to just look for a
    # named file, even if it has a different inode number, or that
    # LilyPond is fixed to not delete the old PDF first, but just
    # truncate it and write the new data into it.

    # Update June 17, 2008: LilyPond >= 2.11.49 does not delete the PDF
    # anymore on unix platforms!

    # Document already shown?
    if _file == pdf:
        # Yes this is the same PDF, see if we need to force KPDF to
        # reload the document. If not, we trust that KPDF automatically
        # updates its view.
        from lilykde.version import version
        if (
            # User can force reload of PDF with config option
            config('preferences')['force reload pdf'] == '1'
            # LilyPond >= 2.11.49 does not delete the PDF anymore on unix
            or version < (2, 11, 49) or os.name not in ('posix', 'mac')
            # read KPDF's 'watch file' option (default is true)
            or kconfig('kpdfpartrc', True, False).group('General')['WatchFile']
                in ('false', '0', 'off', 'no')):
            # Reopen same document, remembering page number
            page = kpdf.currentPage()[1]
            kpdf.openDocument(KURL(pdf))
            QTimer.singleShot(100, lambda: kpdf.goToPage(page))
    else:
        # This is another PDF, just open it.
        kpdf.openDocument(KURL(pdf))
        _file = pdf
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:46,代码来源:pdf.py

示例3: queryExit

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
    def queryExit(self):
        """see queryClose"""
        def quitDebug(*args, **kwargs):
            """reducing branches in queryExit"""
            if Debug.quit:
                logDebug(*args, **kwargs)

        if self.exitReady:
            quitDebug(u'MainWindow.queryExit returns True because exitReady is set')
            return True
        if self.exitConfirmed:
            # now we can get serious
            self.exitReady = False
            for widget in chain(
                    (x.tableList for x in HumanClient.humanClients), [
                        self.confDialog,
                        self.rulesetWindow, self.playerWindow]):
                if isAlive(widget):
                    widget.hide()
            if self.exitWaitTime is None:
                self.exitWaitTime = 0
            if Internal.reactor and Internal.reactor.running:
                self.exitWaitTime += 10
                if self.exitWaitTime % 1000 == 0:
                    logDebug(
                        u'waiting since %d seconds for reactor to stop' %
                        (self.exitWaitTime // 1000))
                try:
                    quitDebug(u'now stopping reactor')
                    Internal.reactor.stop()
                    assert isAlive(self)
                    QTimer.singleShot(10, self.close)
                except ReactorNotRunning:
                    self.exitReady = True
                    quitDebug(
                        u'MainWindow.queryExit returns True: It got exception ReactorNotRunning')
            else:
                self.exitReady = True
                quitDebug(u'MainWindow.queryExit returns True: Reactor is not running')
        return bool(self.exitReady)
开发者ID:KDE,项目名称:kajongg,代码行数:42,代码来源:mainwindow.py

示例4: stopCommand

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
 def stopCommand(self):
     self.resetButtons()
     self.process.tryTerminate()
     QTimer.singleShot(5000, self.process, SLOT("kill()"))
开发者ID:emayssat,项目名称:sandbox,代码行数:6,代码来源:qt3_qproc.py

示例5: closeEvent

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
 def closeEvent(self, event):
     KXmlGuiWindow.closeEvent(self, event)
     if event.isAccepted() and self.exitReady:
         QTimer.singleShot(5000, self.aboutToQuit)
开发者ID:KDE,项目名称:kajongg,代码行数:6,代码来源:mainwindow.py

示例6: action

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
 def action(func):
     QTimer.singleShot(msec, func)
     return func
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:5,代码来源:util.py

示例7: finish

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
    cmd = [pdftk(), pdf, 'attach_files'] + files + ['output', temp]

    try:
        retcode = subprocess.call(cmd, cwd = directory)
    except OSError, e:
        log.fail(_("Could not start Pdftk: %s") % e)
        os.remove(temp)
    else:
        if retcode == 0:
            # copy temp to the pdf, but do it not too quick if wait
            # was specified, otherwise KPDF could still be reading, and
            # will then possibly read a truncated file.
            def finish():
                shutil.copy(temp, pdf)
                os.remove(temp)
                log.ok(_(
                    "Embedded file %s in PDF.",
                    "Embedded files %s in PDF.",
                    len(files)
                    ) % '[%s]' % ', '.join(files))
            QTimer.singleShot(int(wait * 1000), finish)
        else:
            os.remove(temp)
            log.fail('%s %s' % (
                _("Embedding files in PDF failed."),
                _("Return code: %i") % retcode))


# kate: indent-width 4;
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:31,代码来源:pdftk.py

示例8: executeCommandDelayed

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import singleShot [as 别名]
 def executeCommandDelayed(self, method, delay=100):
   # Order of OpenIGTLink message receiving and processing is not guaranteed to be the same
   # therefore we wait a bit to make sure the image message is processed as well
   QTimer.singleShot(delay, method)
开发者ID:SlicerProstate,项目名称:ProstateTRUSNav,代码行数:6,代码来源:ProstateTRUSNav.py


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