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


Python QtCore.QTimer方法代码示例

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


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

示例1: run

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def run(self):
        app = QtGui.QApplication([])
        ## Create window with GraphicsView widget
        win = pg.GraphicsLayoutWidget()
        win.show()  ## show widget alone in its own window
        win.setWindowTitle('pyqtgraph example: ImageItem')
        view = win.addViewBox()

        ## lock the aspect ratio so pixels are always square
        view.setAspectLocked(True)

        ## Create image item
        self.img = pg.ImageItem(border='w')
        view.addItem(self.img)

        ## Set initial view bounds
        view.setRange(QtCore.QRectF(0, 0, 2*self.image_hw, self.image_hw))

        timer = QtCore.QTimer()
        timer.timeout.connect(self._update)
        timer.start(50)

        app.exec_() 
开发者ID:udacity,项目名称:RoboND-DeepLearning-Project,代码行数:25,代码来源:visualization.py

示例2: animation

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def animation(self, frametime=10):
        """
        calls the update method to run in a loop
        """
        timer = QtCore.QTimer()
        timer.timeout.connect(self.update)
        timer.start(frametime)
        self.start() 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:10,代码来源:webcam3d.py

示例3: __init__

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def __init__(self):
        QtGui.QWidget.__init__(self)
        
        self.animations = []
        self.animTimer = QtCore.QTimer()
        self.animTimer.timeout.connect(self.stepAnimation)
        self.animTime = 0
        self.animDt = .016
        self.lastAnimTime = 0
        
        self.setupGUI()
        
        self.objectGroup = ObjectGroupParam()
        
        self.params = Parameter.create(name='params', type='group', children=[
            dict(name='Load Preset..', type='list', values=[]),
            #dict(name='Unit System', type='list', values=['', 'MKS']),
            dict(name='Duration', type='float', value=10.0, step=0.1, limits=[0.1, None]),
            dict(name='Reference Frame', type='list', values=[]),
            dict(name='Animate', type='bool', value=True),
            dict(name='Animation Speed', type='float', value=1.0, dec=True, step=0.1, limits=[0.0001, None]),
            dict(name='Recalculate Worldlines', type='action'),
            dict(name='Save', type='action'),
            dict(name='Load', type='action'),
            self.objectGroup,
            ])
        self.tree.setParameters(self.params, showTop=False)
        self.params.param('Recalculate Worldlines').sigActivated.connect(self.recalculate)
        self.params.param('Save').sigActivated.connect(self.save)
        self.params.param('Load').sigActivated.connect(self.load)
        self.params.param('Load Preset..').sigValueChanged.connect(self.loadPreset)
        self.params.sigTreeStateChanged.connect(self.treeChanged)
        
        ## read list of preset configs
        presetDir = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), 'presets')
        if os.path.exists(presetDir):
            presets = [os.path.splitext(p)[0] for p in os.listdir(presetDir)]
            self.params.param('Load Preset..').setLimits(['']+presets) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:40,代码来源:relativity.py

示例4: __init__

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def __init__(self, settings):
        # Here, you should call the inherited class' init, which is QDialog
        QtGui.QWidget.__init__(self)
        
        print("UIST - UI Settings constructor")
        
        # Application settings data instance
        self.theSettings = settings
        
        # Window settings
        self.setWindowModality(QtCore.Qt.ApplicationModal)
        self.setWindowTitle('Astibot Settings')
        self.setStyleSheet("background-color:#203044;")
        self.setWindowIcon(QtGui.QIcon("AstibotIcon.png"))
        self.setAutoFillBackground(True);
        self.setFixedSize(646, 610)
        
        # Build layout
        self.BuildWindowLayout()
        
        # Timer to make API textboxes blink
        self.timerBlinkStuffs = QtCore.QTimer()
        self.timerBlinkStuffs.timeout.connect(self.TimerRaisedBlinkStuff)    
        self.blinkIsOn = False
        self.blinkCounter = 0
              
        # Apply saved (or default) settings
        self.ApplySettings() 
开发者ID:Florian455,项目名称:Astibot,代码行数:30,代码来源:UISettings.py

示例5: __init__

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def __init__(self, settings):
        # Here, you should call the inherited class' init, which is QDialog
        QtGui.QWidget.__init__(self)
        
        print("UIDO - UI Donating constructor")
        
        # Application settings data instance
        self.theSettings = settings
        
        # Functional
        self.BTCBalance = -1.0
        self.windowIsShown = False
        self.timerRefreshBTCBalance = QtCore.QTimer()
        self.timerRefreshBTCBalance.timeout.connect(self.TimerRaisedRefreshBTCBalance)
        self.timerRefreshBTCBalance.start(200)
        self.withdrawHasBeenPerformed = False
    
        # Window settings
        self.setWindowModality(QtCore.Qt.ApplicationModal)
        self.setWindowTitle('Astibot')
        self.setStyleSheet("background-color:#203044;")
        self.setWindowIcon(QtGui.QIcon("AstibotIcon.png"))
        self.setAutoFillBackground(True);
        self.setFixedSize(450, 350)
        
        # Build layout
        self.BuildWindowLayout() 
开发者ID:Florian455,项目名称:Astibot,代码行数:29,代码来源:UIDonation.py

示例6: _start

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def _start():
    '''Start the module
    This uses the global variables from setup and adds a set of global variables
    '''
    global parser, args, config, r, response, patch, name
    global monitor, delay, winx, winy, winwidth, winheight, input_name, input_variable, variable, app, window, timer

    # this can be used to show parameters that have changed
    monitor = EEGsynth.monitor(name=name, debug=patch.getint('general', 'debug'))

    # get the options from the configuration file
    delay           = patch.getfloat('general', 'delay')
    winx            = patch.getfloat('display', 'xpos')
    winy            = patch.getfloat('display', 'ypos')
    winwidth        = patch.getfloat('display', 'width')
    winheight       = patch.getfloat('display', 'height')

    # get the input options
    input_name, input_variable = list(zip(*config.items('input')))

    for name,variable in zip(input_name, input_variable):
        monitor.info("%s = %s" % (name, variable))

    # start the graphical user interface
    app = QtGui.QApplication(sys.argv)
    signal.signal(signal.SIGINT, _stop)

    window = Window()
    window.show()

    # Set timer for update
    timer = QtCore.QTimer()
    timer.timeout.connect(_loop_once)
    timer.setInterval(10)            # timeout in milliseconds
    timer.start(int(delay * 1000))   # in milliseconds

    # there should not be any local variables in this function, they should all be global
    if len(locals()):
        print('LOCALS: ' + ', '.join(locals().keys())) 
开发者ID:eegsynth,项目名称:eegsynth,代码行数:41,代码来源:vumeter.py

示例7: animation

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def animation(self):
        timer = QtCore.QTimer()
        timer.timeout.connect(self.update)
        timer.start(1)
        self.start() 
开发者ID:zh-plus,项目名称:video-to-pose3D,代码行数:7,代码来源:amination.py

示例8: _loop_once

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def _loop_once():
    '''Run the main loop once
    This uses the global variables from setup and start, and adds a set of global variables
    '''
    global parser, args, config, r, response, patch
    global monitor, debug, delay, window, value, winx, winy, winwidth, winheight, data, lock, trigger, number, i, this, thread, app, win, plot

    monitor.loop()

    now = time.time()
    plot.clear()
    for y in number:
        for event in data[y]:
            x = event[0] - now      # time
            v = event[1]            # value

            if x < -window-0.5:
                # remove the event if it is too far in the past
                data[y].remove(event)
                continue

            scatter = pg.ScatterPlotItem()
            scatter.addPoints([{'pos': (x, y)}])
            plot.addItem(scatter)

            if value:
                # show the numeric value next to the trigger

                if abs(v-round(v))<0.001:
                    # print it as integer value
                    s = '%d' % v
                else:
                    # print it as floating point value
                    s = '%2.1f' % v

                text = pg.TextItem(s, anchor=(0,0))
                text.setPos(x, y)
                plot.addItem(text)

    signal.signal(signal.SIGINT, _stop)

    # Set timer for update
    timer = QtCore.QTimer()
    timer.timeout.connect(_loop_once)
    timer.setInterval(10)                     # timeout in milliseconds
    timer.start(int(round(delay * 1000)))     # in milliseconds

    # there should not be any local variables in this function, they should all be global
    if len(locals()):
        print('LOCALS: ' + ', '.join(locals().keys())) 
开发者ID:eegsynth,项目名称:eegsynth,代码行数:52,代码来源:plottrigger.py

示例9: _start

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def _start():
    '''Start the module
    This uses the global variables from setup and adds a set of global variables
    '''
    global parser, args, config, r, response, patch, name
    global monitor, debug, prefix, winx, winy, winwidth, winheight, output_scale, output_offset

    # this can be used to show parameters that have changed
    monitor = EEGsynth.monitor(name=name, debug=patch.getint('general', 'debug'))

    # get the options from the configuration file
    debug = patch.getint('general', 'debug')
    prefix = patch.getstring('output', 'prefix')
    winx = patch.getfloat('display', 'xpos')
    winy = patch.getfloat('display', 'ypos')
    winwidth = patch.getfloat('display', 'width')
    winheight = patch.getfloat('display', 'height')

    # the scale and offset are used to map internal values to Redis values
    output_scale = patch.getfloat('output', 'scale', default=1. / 127)  # internal values are from 0 to 127
    output_offset = patch.getfloat('output', 'offset', default=0.)    # internal values are from 0 to 127

    if 'initial' in config.sections():
        # assign the initial values
        for item in config.items('initial'):
            val = patch.getfloat('initial', item[0])
            patch.setvalue(item[0], val)
            monitor.update(item[0], val)

    # start the graphical user interface
    app = QtGui.QApplication(sys.argv)
    signal.signal(signal.SIGINT, _stop)

    # Let the interpreter run every 200 ms
    # see https://stackoverflow.com/questions/4938723/what-is-the-correct-way-to-make-my-pyqt-application-quit-when-killed-from-the-co/6072360#6072360
    timer = QtCore.QTimer()
    timer.start(400)
    timer.timeout.connect(lambda: None)

    ex = Window()
    ex.show()
    sys.exit(app.exec_()) 
开发者ID:eegsynth,项目名称:eegsynth,代码行数:44,代码来源:inputcontrol.py

示例10: main

# 需要导入模块: from pyqtgraph.Qt import QtCore [as 别名]
# 或者: from pyqtgraph.Qt.QtCore import QTimer [as 别名]
def main():
    # firstly resolve all streams that could be shown
    inlets: List[Inlet] = []
    print("looking for streams")
    streams = pylsl.resolve_streams()

    # Create the pyqtgraph window
    pw = pg.plot(title='LSL Plot')
    plt = pw.getPlotItem()
    plt.enableAutoRange(x=False, y=True)

    # iterate over found streams, creating specialized inlet objects that will
    # handle plotting the data
    for info in streams:
        if info.type() == 'Markers':
            if info.nominal_srate() != pylsl.IRREGULAR_RATE \
                    or info.channel_format() != pylsl.cf_string:
                print('Invalid marker stream ' + info.name())
            print('Adding marker inlet: ' + info.name())
            inlets.append(MarkerInlet(info))
        elif info.nominal_srate() != pylsl.IRREGULAR_RATE \
                and info.channel_format() != pylsl.cf_string:
            print('Adding data inlet: ' + info.name())
            inlets.append(DataInlet(info, plt))
        else:
            print('Don\'t know what to do with stream ' + info.name())

    def scroll():
        """Move the view so the data appears to scroll"""
        # We show data only up to a timepoint shortly before the current time
        # so new data doesn't suddenly appear in the middle of the plot
        fudge_factor = pull_interval * .002
        plot_time = pylsl.local_clock()
        pw.setXRange(plot_time - plot_duration + fudge_factor, plot_time - fudge_factor)

    def update():
        # Read data from the inlet. Use a timeout of 0.0 so we don't block GUI interaction.
        mintime = pylsl.local_clock() - plot_duration
        # call pull_and_plot for each inlet.
        # Special handling of inlet types (markers, continuous data) is done in
        # the different inlet classes.
        for inlet in inlets:
            inlet.pull_and_plot(mintime, plt)

    # create a timer that will move the view every update_interval ms
    update_timer = QtCore.QTimer()
    update_timer.timeout.connect(scroll)
    update_timer.start(update_interval)

    # create a timer that will pull and add new data occasionally
    pull_timer = QtCore.QTimer()
    pull_timer.timeout.connect(update)
    pull_timer.start(pull_interval)

    import sys

    # Start Qt event loop unless running in interactive mode or using pyside.
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_() 
开发者ID:labstreaminglayer,项目名称:liblsl-Python,代码行数:61,代码来源:ReceiveAndPlot.py


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