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


Python qt.QTimer类代码示例

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


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

示例1: ui

class BackGround:
    """ class that provides a timer that checks on background processes,
    and method for adding new background workers. all workers should provide following methods:
    ui(),bg() """
    def __init__(self):
        self.workers = {}
        self.checkTimer = QTimer()
        self.checkTimer.connect(self.checkTimer, SIGNAL("timeout()"), self.check)
        self.checkTimer.start(500)
    
    def check(self):
        for worker in self.workers.keys():
            if not self.workers[worker].THREAD.isAlive():
                self.workers[worker].ui()
                if self.workers[worker].SENDER: 
                    self.workers[worker].SENDER.setEnabled(True)
                del self.workers[worker]
            else:
                self.workers[worker].status()

    def add(self, worker, sender=None):
        if self.workers.has_key(str(worker)): # only add unique workers!
            return False
        worker.THREAD = Thread(args = [worker], target = worker.bg)
        worker.THREAD.start()
        if sender:
            sender.setEnabled(False)            
        worker.SENDER = sender
        self.workers[str(worker)] = worker
        return True
开发者ID:BackupTheBerlios,项目名称:pyqlogger-svn,代码行数:30,代码来源:BG.py

示例2: RunnerWidget

class RunnerWidget(QWidget):
    def __init__(self, parent, umlmachines, name='RunnerWidget'):
        QWidget.__init__(self, parent, name)
        self.app = get_application_pointer()
        self.umlmachines = umlmachines
        self.proc = self.umlmachines.run_machine()
        self._mainbox = QVBoxLayout(self, 5, 7)
        # add label
        self.mainlabel = QLabel(self)
        self.mainlabel.setText('Running Umlmachine %s' % self.umlmachines.current)
        self._mainbox.addWidget(self.mainlabel)
        # add stdout viewer
        logfile = self.umlmachines.stdout_logfile.name
        self.logbrowser = LogBrowser(self, logfile)
        self._mainbox.addWidget(self.logbrowser)
        self.timer = QTimer(self)
        self.connect(self.timer, SIGNAL('timeout()'), self.update_progress)
        self.timer.startTimer(1000)
        
    def update_progress(self):
        #retval = self.proc.poll()
        #print retval
        retval = None
        if retval is not None:
            print retval
            self.close()
开发者ID:joelsefus,项目名称:paella,代码行数:26,代码来源:runner.py

示例3: BootStrapperWidget

class BootStrapperWidget(QWidget):
    def __init__(self, parent, suite, name="RunnerWidget"):
        QWidget.__init__(self, parent, name)
        self.app = get_application_pointer()
        cfg = self.app.umlcfg
        basefile = make_base_filesystem(suite, "%s.base" % suite, cfg=cfg, size=300, mkfs="mke2fs")
        self.bootstrapper = UmlBootstrapper(suite, basefile, cfg=self.cfg)
        self._mainbox = QVBoxLayout(self, 5, 7)
        # add label
        self.mainlabel = QLabel(self)
        self.mainlabel.setText("Bootstrapping suite %s" % suite)
        self._mainbox.addWidget(self.mainlabel)
        # add stdout viewer
        logfile = self.umlmachines.stdout_logfile.name
        self.logbrowser = LogBrowser(self, logfile)
        self._mainbox.addWidget(self.logbrowser)
        self.timer = QTimer(self)
        self.connect(self.timer, SIGNAL("timeout()"), self.update_progress)
        self.timer.startTimer(1000)

    def update_progress(self):
        # retval = self.proc.poll()
        # print retval
        retval = None
        if retval is not None:
            print retval
            self.close()
开发者ID:joelsefus,项目名称:paella,代码行数:27,代码来源:bootstrapper.py

示例4: __init__

    def __init__(self, parent, updateinterval):
        SurfacePlot.__init__(self, parent)

        self.setRotation(30, 0, 15)
        self.setShift(0.1, 0, 0)
        self.setZoom(0.8)
        self.coordinates().setNumberFont("Courier", 8)
        
        axes = self.coordinates().axes # alias
        for axis in axes:
            axis.setMajors(7)
            axis.setMinors(4)

        axes[X1].setLabelString("x")
        axes[Y1].setLabelString("y")
        axes[Z1].setLabelString("z")
        axes[X2].setLabelString("x")
        axes[Y2].setLabelString("y")
        axes[Z2].setLabelString("z")
        axes[X3].setLabelString("x")
        axes[Y3].setLabelString("y")
        axes[Z3].setLabelString("z")
        axes[X4].setLabelString("x")
        axes[Y4].setLabelString("y")
        axes[Z4].setLabelString("z")

        timer = QTimer(self)
        self.connect(timer, SIGNAL('timeout()'), self.rotate)
        timer.start(updateinterval)
开发者ID:PyQwt,项目名称:PyQwt3D,代码行数:29,代码来源:AutoSwitch.py

示例5: __init__

    def __init__(self):
        KApplication.__init__(self)
        # in case something needs done before quitting
        self.connect(self, SIGNAL('aboutToQuit()'), self.quit)
        self.dcop = ToolBoxDCOPInterface()
        self._setup_standard_directories()
        #self._generate_data_directories()
        dbfile = os.path.join(self.datadir, 'main.db')
        #self.conn = Connection(dbname=dbfile, autocommit=True,
        #                       encoding='ascii')
        #self.guests = Guests(self.conn)
        #self.db = EntityManager(self.conn)
        from sqlalchemy import create_engine
        from sqlalchemy.orm import sessionmaker
        self.engine = create_engine('sqlite:///%s' % dbfile)
        if not self.engine.table_names():
            from newschema import metadata
            metadata.create_all(self.engine)
        self.DbSession = sessionmaker(bind=self.engine,
                                      autoflush=True, transactional=False)
        self.session = self.DbSession()
        self.db = EntityManager(self.session)
        
        self.urlhandler = MainUrlHandler(self)
        self.filehandler = BaseFileHandler(self)
        
        # setup the timer to handle background jobs
        self.timer = QTimer()
        # every five seconds
        self.timer.changeInterval(1000)
        self.connect(self.timer, SIGNAL('timeout()'), self._timer_done)

        self.main_window = None
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:33,代码来源:application.py

示例6: setup

  def setup(self):
    self.widget = QWidget()
    layout = QGridLayout()
    self.widget.setLayout(layout)
    self.layout.addWidget(self.widget)
    self.widget.show()
    self.layout = layout

    self.setupInputFrame()
    self.setupFrameControlFrame()
    self.setupAdditionalFrames()
    self.setupPlottingFrame()

    self.setFramesEnabled(False)

    self.timer = QTimer()
    self.timer.setInterval(50)

    self.setupConnections()

    # initialize slice observers (from DataProbe.py)
    # keep list of pairs: [observee,tag] so they can be removed easily
    self.styleObserverTags = []
    # keep a map of interactor styles to sliceWidgets so we can easily get sliceLogic
    self.sliceWidgetsPerStyle = {}
    self.refreshObservers()
开发者ID:naucoin,项目名称:MultiVolumeExplorer,代码行数:26,代码来源:qSlicerMultiVolumeExplorerModuleWidget.py

示例7: __init__

 def __init__(self, notifier):
     from pyqlogger import VERSION
     self.notifier = notifier
     self.notified = LooseVersion(VERSION)
     self.Timer = QTimer()
     self.Timer.connect(self.Timer, SIGNAL("timeout()"), self.work)
     self.Timer.start(60*60*1000)    
开发者ID:BackupTheBerlios,项目名称:pyqlogger-svn,代码行数:7,代码来源:BG.py

示例8: BaseLogBrowser

class BaseLogBrowser(KTextBrowser):
    def __init__(self, parent, name='BaseLogBrowser'):
        KTextBrowser.__init__(self, parent, name)
        self.setTextFormat(self.LogText)
        self.timer = QTimer(self)
        self.connect(self.timer, SIGNAL('timeout()'), self.update_logtext)
        self.resume_logging()
        
    def pause_logging(self):
        self.timer.stop()

    def resume_logging(self):
        self.timer.start(500)
        
    def update_logtext(self):
        raise NotImplementedError
开发者ID:joelsefus,项目名称:paella,代码行数:16,代码来源:widgets.py

示例9: __init__

 def __init__(self, parent, umlmachines, name="InstallerWidget"):
     QWidget.__init__(self, parent, name)
     self.resize(600, 600)
     self.app = get_application_pointer()
     self.conn = self.app.conn
     self.umlmachines = umlmachines
     self.machine = self.umlmachines.current
     self.current_machine_process = "start"
     self.current_profile = None
     self.current_trait = None
     self.traitlist = []
     self.curenv = CurrentEnvironment(self.conn, self.machine)
     self.curenv["current_profile"] = "None"
     self.curenv["current_trait"] = "None"
     self.curenv["current_machine_process"] = self.current_machine_process
     self.timer = QTimer(self)
     self.connect(self.timer, SIGNAL("timeout()"), self.update_progress)
     self.timer.startTimer(1000)
     self.grid = QGridLayout(self, 4, 1, 5, 7)
     self.main_label = QLabel(self)
     self.main_label.setText(self._msg())
     self.grid.addWidget(self.main_label, 0, 0)
     self.profile_progress_lbl = QLabel(self)
     self.grid.addWidget(self.profile_progress_lbl, 1, 0)
     self.profile_progress = KProgress(self)
     self.grid.addWidget(self.profile_progress, 2, 0)
     self.logview = LogBrowser(self, "/tmp/uml-installer.log")
     self.grid.addWidget(self.logview, 3, 0)
     # self.console_view = StdOutBrowser(self)
     # self.console_view = KTextBrowser(self)
     # self.grid.addWidget(self.console_view, 4, 0)
     self.console_text = ""
开发者ID:joelsefus,项目名称:paella,代码行数:32,代码来源:installer.py

示例10: refresh

 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,代码行数:47,代码来源:scoringdialog.py

示例11: simulate

    def simulate(self):
        global _timer
        if _timer: _timer.stop()
        if not self.running:
            self.running = 1
            self.qApp.exit_loop()
            return
        self.runUntilCurrent()

        # gah
        timeout = self.timeout()
        if timeout is None: timeout = 1.0
        timeout = min(timeout, 0.1) * 1010

        if not _timer:
            _timer = QTimer()
            QObject.connect( _timer, SIGNAL("timeout()"), self.simulate )
        _timer.start(timeout, 1)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:18,代码来源:qtreactor.py

示例12: openFile

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,代码行数:44,代码来源:pdf.py

示例13: __init__

 def __init__(self, parent):
     QObject.__init__(self)
     self.parent = parent
     # Modal dialogs freezes pm in dbus signal path
     self.delayTimer = QTimer(self)
     self.lastError = None
     ##
     self.connect(self.delayTimer, SIGNAL("timeout()"), self.exceptionHandler)
     self.iface = PisiIface.Iface()
     self.iface.setHandler(self.handler)
     self.iface.setExceptionHandler(self.exceptionHandler)
开发者ID:Tayyib,项目名称:uludag,代码行数:11,代码来源:Commander.py

示例14: __init__

    def __init__(self):
        QObject.__init__(self)
        self.sysTray = KMySystemTray()
        self.sysTray.setPixmap(self.sysTray.loadIcon("ksmarttray"))
        self.sysTray.show()
    
        self.process = KProcIO()
    
        self.state = KSmartTray.State.Waiting
        self.lastKnownStatus = ""
    
        self.blinkFlag = False
        self.updateFailed = False
    
        self.checkTimer = QTimer()
        self.blinkTimer = QTimer()

        QObject.connect(self.checkTimer, SIGNAL("timeout()"), self.checkUpgrades)
        QObject.connect(self.process, SIGNAL("processExited(KProcess *)"),
                self.processDone)
    
        QObject.connect(self, PYSIGNAL("foundNewUpgrades()"), self.startBlinking)
        QObject.connect(self, PYSIGNAL("foundNoUpgrades()"), self.stopBlinking)
        QObject.connect(self.sysTray, PYSIGNAL("mouseEntered()"), self.stopBlinking)
        QObject.connect(self.blinkTimer, SIGNAL("timeout()"), self.toggleBlink)
    
        QObject.connect(self.sysTray.checkAction, SIGNAL("activated()"),
                self.manualCheckUpgrades)
        QObject.connect(self.sysTray.startSmartAction, SIGNAL("activated()"),
                self.startSmart)
        QObject.connect(self.sysTray.stopAction, SIGNAL("activated()"),
                self.stopChecking)
        QObject.connect(self.sysTray, SIGNAL("quitSelected()"),
                KApplication.kApplication(), SLOT("quit()"))
    
        QObject.connect(self.sysTray, PYSIGNAL("activated()"), self.runUpgrades)
    
        self.checkTimer.start(5*60*1000)
    
        self.checkUpgrades()
开发者ID:blackPantherOS,项目名称:packagemanagement,代码行数:40,代码来源:ksmarttray.py

示例15: queryExit

    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,代码行数:40,代码来源:mainwindow.py


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