當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。