• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python logging.data函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: waitKeys

def waitKeys(maxWait=float('inf'), keyList=None, timeStamped=False):
    """
    Same as `~psychopy.event.getKeys`, but halts everything (including drawing) while awaiting
    input from keyboard. Implicitly clears keyboard, so any preceding keypresses will be lost.

    :Parameters:
        maxWait : any numeric value.
            Maximum number of seconds period and which keys to wait for.
            Default is float('inf') which simply waits forever.

    Returns None if times out.
    """

    #NB pygame.event does have a wait() function that will
    #do this and maybe leave more cpu idle time?
    key = None
    clearEvents('keyboard')  # So that we only take presses from here onwards.

    # Check for keypresses until maxWait is exceeded
    timer = psychopy.core.Clock()
    while key == None and timer.getTime() < maxWait:
        # Pump events on pyglet windows if they exist
        if havePyglet:
            wins = pyglet.window.get_platform().get_default_display().get_windows()
            for win in wins: win.dispatch_events()

        # Get keypresses and return if anything is pressed
        keys = getKeys(keyList=keyList, timeStamped=timeStamped)
        if len(keys):
            return keys

    # If maxWait is exceeded (exits while-loop), return None
    logging.data("No keypress (maxWait exceeded)")
    return None
开发者ID:JasonLocklin,项目名称:psychopy,代码行数:34,代码来源:event.py


示例2: _record

    def _record(self, sec, filename='', block=True):
        while self.recorder.running:
            pass
        self.duration = float(sec)
        self.onset = core.getTime()  # for duration estimation, high precision
        self.fileOnset = core.getAbsTime()  # for log and filename, 1 sec precision
        logging.data('%s: Record: onset %d, capture %.3fs' %
                     (self.loggingId, self.fileOnset, self.duration) )
        if not file:
            onsettime = '-%d' % self.fileOnset
            self.savedFile = onsettime.join(os.path.splitext(self.wavOutFilename))
        else:
            self.savedFile = os.path.abspath(filename).strip('.wav') + '.wav'

        t0 = core.getTime()
        self.recorder.run(self.savedFile, self.duration, **self.options)

        self.rate = sound.pyoSndServer.getSamplingRate()
        if block:
            core.wait(self.duration, 0)
            logging.exp('%s: Record: stop. %.3f, capture %.3fs (est)' %
                     (self.loggingId, core.getTime(), core.getTime() - t0) )
            while self.recorder.running:
                core.wait(.001, 0)
        else:
            logging.exp('%s: Record: return immediately, no blocking' %
                     (self.loggingId) )

        return self.savedFile
开发者ID:DiogoamCoutinho,项目名称:stimulus.py,代码行数:29,代码来源:microphone.py


示例3: record

    def record(self, sec, file='', block=True):
        """Capture sound input for duration <sec>, save to a file.

        Return the path/name to the new file. Uses onset time (epoch) as
        a meaningful identifier for filename and log.
        """
        while self.recorder.running:
            pass
        self.duration = float(sec)
        self.onset = core.getTime() # note: report onset time in log, and use in filename
        logging.data('%s: Record: onset %.3f, capture %.3fs' %
                     (self.loggingId, self.onset, self.duration) )
        if not file:
            onsettime = '-%.3f' % self.onset
            self.savedFile = onsettime.join(os.path.splitext(self.wavOutFilename))
        else:
            self.savedFile = os.path.abspath(file).strip('.wav') + '.wav'

        t0 = core.getTime()
        self.recorder.run(self.savedFile, self.duration, self.sampletype)
        self.rate = sound.pyoSndServer.getSamplingRate()

        if block:
            core.wait(self.duration - .0008) # .0008 fudge factor for better reporting
                # actual timing is done by Clean_objects
            logging.exp('%s: Record: stop. %.3f, capture %.3fs (est)' %
                     (self.loggingId, core.getTime(), core.getTime() - t0) )
        else:
            logging.exp('%s: Record: return immediately, no blocking' %
                     (self.loggingId) )

        return self.savedFile
开发者ID:RainyJupiter,项目名称:psychopy,代码行数:32,代码来源:microphone.py


示例4: _record

    def _record(self, sec, filename="", block=True, log=True):
        while self.recorder.running:
            pass
        self.duration = float(sec)
        self.onset = core.getTime()  # for duration estimation, high precision
        self.fileOnset = core.getAbsTime()  # for log and filename, 1 sec precision
        ms = "%.3f" % (core.getTime() - int(core.getTime()))
        if log and self.autoLog:
            logging.data("%s: Record: onset %d, capture %.3fs" % (self.loggingId, self.fileOnset, self.duration))
        if not filename:
            onsettime = "-%d" % self.fileOnset + ms[1:]
            self.savedFile = onsettime.join(os.path.splitext(self.wavOutFilename))
        else:
            self.savedFile = os.path.abspath(filename).strip(".wav") + ".wav"

        t0 = core.getTime()
        self.recorder.run(self.savedFile, self.duration, **self.options)

        self.rate = sound.pyoSndServer.getSamplingRate()
        if block:
            core.wait(self.duration, 0)
            if log and self.autoLog:
                logging.exp(
                    "%s: Record: stop. %.3f, capture %.3fs (est)"
                    % (self.loggingId, core.getTime(), core.getTime() - t0)
                )
            while self.recorder.running:
                core.wait(0.001, 0)
        else:
            if log and self.autoLog:
                logging.exp("%s: Record: return immediately, no blocking" % (self.loggingId))

        return self.savedFile
开发者ID:rpbaxter,项目名称:psychopy,代码行数:33,代码来源:microphone.py


示例5: _onPygletKey

def _onPygletKey(symbol, modifiers, emulated=False):
    """handler for on_key_press pyglet events, or call directly to emulate a key press

    Appends a tuple with (keyname, timepressed) into the global _keyBuffer. The
    _keyBuffer can then be accessed as normal using event.getKeys(), .waitKeys(),
    clearBuffer(), etc.

    J Gray 2012: Emulated means add a key (symbol) to the buffer virtually.
    This is useful for fMRI_launchScan, and for unit testing (in testTheApp)
    Logging distinguished EmulatedKey events from real Keypress events.
    For emulation, the key added to the buffer is unicode(symbol), instead of
    pyglet.window.key.symbol_string(symbol)

    S Mathot 2012: Implement fallback to _onPygletText
    """

    global useText
    keyTime=psychopy.core.getTime() #capture when the key was pressed
    if emulated:
        thisKey = unicode(symbol)
        keySource = 'EmulatedKey'
    else:
        thisKey = pyglet.window.key.symbol_string(symbol).lower() #convert symbol into key string
        #convert pyglet symbols to pygame forms ( '_1'='1', 'NUM_1'='[1]')
        # 'user_key' indicates that Pyglet has been unable to make sense out of
        # the keypress. In that case, we fall back to _onPygletText to handle
        # the input.
        if 'user_key' in thisKey:
            useText = True
            return
        useText = False
        thisKey = thisKey.lstrip('_').lstrip('NUM_')
        keySource = 'Keypress'
    _keyBuffer.append( (thisKey,keyTime) ) # tuple
    logging.data("%s: %s" % (keySource, thisKey))
开发者ID:BrainTech,项目名称:psychopy,代码行数:35,代码来源:event.py


示例6: _onGLFWKey

def _onGLFWKey(*args, **kwargs):
    """Callback for key/character events for the GLFW backend.

    :return:
    """
    keyTime = psychopy.core.getTime()  # get timestamp

    # TODO - support for key emulation
    win_ptr, key, scancode, action, modifiers = args
    global useText
    
    if key == glfw.KEY_UNKNOWN:
        useText = True
        return
    useText = False

    # get the printable name, always make lowercase
    key_name = glfw.get_key_name(key, scancode)

    # if there is no localized key name or space
    if key_name is None or key_name == ' ':
        try:
            key_name = _glfw_keycodes_[key]
        except KeyError:
            pass
    else:
        key_name = key_name.lower()

    # TODO - modifier integration
    keySource = 'Keypress'
    _keyBuffer.append((key_name, modifiers, keyTime))  # tuple
    logging.data("%s: %s" % (keySource, key_name))
开发者ID:mmagnuski,项目名称:psychopy,代码行数:32,代码来源:event.py


示例7: record

    def record(self, sec, block=True):
        """Capture sound input for duration <sec>, save to a file.
        
        Return the path/name to the new file. Uses onset time (epoch) as
        a meaningful identifier for filename and log.
        """
        RECORD_SECONDS = float(sec)
        self.onset = time.time() # note: report onset time in log, and use in filename
        logging.data('%s: Record: onset %.3f, capture %.3fs' %
                     (self.loggingId, self.onset, RECORD_SECONDS) )
        
        self.savedFile = self.wavOutFilename.replace(ONSET_TIME_HERE, '-%.3f' % self.onset)
        inputter = Input(chnl=0, mul=1) # chnl=[0,1] for stereo input
        t0 = time.time()
        # launch the recording, saving to file:
        recorder = Record(inputter,
                        self.savedFile,
                        chnls=2,
                        fileformat=0, # .wav format
                        sampletype=0,
                        buffering=4) # 4 is default
        # launch recording, block as needed, and clean up:
        clean = Clean_objects(RECORD_SECONDS, recorder) # set up to stop recording
        clean.start() # the timer starts now, ends automatically whether block or not
        if block:
            time.sleep(RECORD_SECONDS - 0.0008) # Clean_objects() set-up takes ~0.0008s, for me
            logging.exp('%s: Record: stop. %.3f, capture %.3fs (est)' %
                     (self.loggingId, time.time(), time.time() - t0) )
        else:
            logging.exp('%s: Record: return immediately, no blocking' %
                     (self.loggingId) )
        
        self.duration = RECORD_SECONDS # used in playback()

        return self.savedFile # filename, or None
开发者ID:jsalva,项目名称:psychopy,代码行数:35,代码来源:microphone.py


示例8: _onPygletText

def _onPygletText(text, emulated=False):
    """handler for on_text pyglet events, or call directly to emulate a text
    event.

    S Mathot 2012: This function only acts when the key that is pressed
    corresponds to a non-ASCII text character (Greek, Arabic, Hebrew, etc.).
    In that case the symbol that is passed to _onPygletKey() is translated
    into a useless 'user_key()' string. If this happens, _onPygletText takes
    over the role of capturing the key. Unfortunately, _onPygletText()
    cannot solely handle all input, because it does not respond to spacebar
    presses, etc.
    """

    global useText
    if not useText:  # _onPygletKey has handled the input
        return
    # This is needed because sometimes the execution
    # sequence is messed up (somehow)
    useText = False
    # capture when the key was pressed:
    keyTime = psychopy.core.getTime()
    if emulated:
        keySource = 'EmulatedKey'
    else:
        keySource = 'KeyPress'
    _keyBuffer.append((text.lower(), lastModifiers, keyTime))
    logging.data("%s: %s" % (keySource, text))
开发者ID:hoechenberger,项目名称:psychopy,代码行数:27,代码来源:event.py


示例9: _onGLFWMouseScroll

def _onGLFWMouseScroll(*args, **kwargs):
    """Callback for mouse scrolling events. For most computer mice with scroll
    wheels, only the vertical (Y-offset) is relevant.

    """
    window_ptr, x_offset, y_offset = args
    global mouseWheelRel
    mouseWheelRel = mouseWheelRel + numpy.array([x_offset, y_offset])
    msg = "Mouse: wheel shift=(%i,%i)"
    logging.data(msg % (x_offset, y_offset))
开发者ID:mmagnuski,项目名称:psychopy,代码行数:10,代码来源:event.py


示例10: _onPygletMouseRelease

def _onPygletMouseRelease(x,y, button, modifiers):
    global mouseButtons
    if button == pyglet.window.mouse.LEFT:
        mouseButtons[0]=0
        label='Left'
    if button == pyglet.window.mouse.MIDDLE:
        mouseButtons[1]=0
        label='Middle'
    if button == pyglet.window.mouse.RIGHT:
        mouseButtons[2]=0
        label='Right'
    logging.data("Mouse: %s button up, pos=(%i,%i)" %(label, x,y))
开发者ID:BrainTech,项目名称:psychopy,代码行数:12,代码来源:event.py


示例11: _onPygletKey

def _onPygletKey(symbol, modifiers, emulated=False):
    """handler for on_key_press pyglet events; call directly to emulate a
    key press

    Appends a tuple with (keyname, timepressed) into the global _keyBuffer.
    The _keyBuffer can then be accessed as normal using event.getKeys(),
    .waitKeys(), clearBuffer(), etc.

    J Gray 2012: Emulated means add a key (symbol) to the buffer virtually.
    This is useful for fMRI_launchScan, and for unit testing (in testTheApp)
    Logging distinguishes EmulatedKey events from real Keypress events.
    For emulation, the key added to the buffer is unicode(symbol), instead of
    pyglet.window.key.symbol_string(symbol).

    S Mathot 2012: Implement fallback to _onPygletText

    5AM Solutions 2016: Add the keyboard modifier flags to the key buffer.

    M Cutone 2018: Added GLFW backend support.

    """
    global useText, lastModifiers

    keyTime = psychopy.core.getTime()  # capture when the key was pressed
    if emulated:
        if not isinstance(modifiers, int):
            msg = 'Modifiers must be passed as an integer value.'
            raise ValueError(msg)

        thisKey = str(symbol)
        keySource = 'EmulatedKey'
    else:
        thisKey = pyglet.window.key.symbol_string(
            symbol).lower()  # convert symbol into key string
        # convert pyglet symbols to pygame forms ( '_1'='1', 'NUM_1'='[1]')
        # 'user_key' indicates that Pyglet has been unable to make sense
        # out of the keypress. In that case, we fall back to _onPygletText
        # to handle the input.
        if 'user_key' in thisKey:
            useText = True
            lastModifiers = modifiers
            return
        useText = False
        thisKey = thisKey.lstrip('_').lstrip('NUM_')
        # Pyglet 1.3.0 returns 'enter' when Return key (0xFF0D) is pressed 
        # in Windows Python3. So we have to replace 'enter' with 'return'.
        if thisKey == 'enter':
            thisKey = 'return'
        keySource = 'Keypress'
    _keyBuffer.append((thisKey, modifiers, keyTime))  # tuple
    logging.data("%s: %s" % (keySource, thisKey))
    _process_global_event_key(thisKey, modifiers)
开发者ID:hoechenberger,项目名称:psychopy,代码行数:52,代码来源:event.py


示例12: stop

    def stop(self):
        """Interrupt a recording that is in progress; close & keep the file.

        Ends the recording before the duration that was initially specified. The
        same file name is retained, with the same onset time but a shorter duration.

        The same recording cannot be resumed after a stop (it is not a pause),
        but you can start a new one.
        """
        if not self.recorder.running:
            logging.exp('%s: Stop requested, but no record() in progress' % self.loggingId )
            return
        self.duration = core.getTime() - self.onset  # new shorter duration
        self.recorder.stop()
        logging.data('%s: Record stopped early, new duration %.3fs' % (self.loggingId, self.duration))
开发者ID:RainyJupiter,项目名称:psychopy,代码行数:15,代码来源:microphone.py


示例13: _onPygletMousePress

def _onPygletMousePress(x,y, button, modifiers):
    global mouseButtons, mouseClick, mouseTimes
    if button == pyglet.window.mouse.LEFT:
        mouseButtons[0]=1
        mouseTimes[0]= psychopy.clock.getTime()-mouseClick[0].getLastResetTime()
        label='Left'
    if button == pyglet.window.mouse.MIDDLE:
        mouseButtons[1]=1
        mouseTimes[1]= psychopy.clock.getTime()-mouseClick[1].getLastResetTime()
        label='Middle'
    if button == pyglet.window.mouse.RIGHT:
        mouseButtons[2]=1
        mouseTimes[2]= psychopy.clock.getTime()-mouseClick[2].getLastResetTime()
        label='Right'
    logging.data("Mouse: %s button down, pos=(%i,%i)" %(label, x,y))
开发者ID:BrainTech,项目名称:psychopy,代码行数:15,代码来源:event.py


示例14: _onPygletMouseRelease

def _onPygletMouseRelease(x, y, button, modifiers, emulated=False):
    global mouseButtons
    if emulated:
        label = 'Emulated'
    else:
        label = ''
    if button & LEFT:
        mouseButtons[0] = 0
        label += ' Left'
    if button & MIDDLE:
        mouseButtons[1] = 0
        label += ' Middle'
    if button & RIGHT:
        mouseButtons[2] = 0
        label += ' Right'
    logging.data("Mouse: %s button up, pos=(%i,%i)" % (label, x, y))
开发者ID:mmagnuski,项目名称:psychopy,代码行数:16,代码来源:event.py


示例15: _onGLFWText

def _onGLFWText(*args, **kwargs):
    """Handle unicode character events if _onGLFWKey() cannot.

    :return:
    """
    keyTime = psychopy.core.getTime()  # get timestamp



    # TODO - support for key emulation
    win_ptr, codepoint, modifiers = args
    # win = glfw.get_window_user_pointer(win_ptr)
    text = chr(codepoint)  # convert to unicode character (Python 3.0)
    global useText
    if not useText:  # _onPygletKey has handled the input
        return
    keySource = 'KeyPress'
    _keyBuffer.append((text, keyTime))
    logging.data("%s: %s" % (keySource, text))
开发者ID:mmagnuski,项目名称:psychopy,代码行数:19,代码来源:event.py


示例16: _record

    def _record(self, sec, filename='', block=True, log=True):
        filename = pathToString(filename)
        while self.recorder.running:
            pass
        self.duration = float(sec)
        # for duration estimation, high precision:
        self.onset = core.getTime()
        # use time for unique log and filename, 1 sec precision
        self.fileOnset = core.getAbsTime()
        ms = "%.3f" % (core.getTime() - int(core.getTime()))
        if log and self.autoLog:
            msg = '%s: Record: onset %d, capture %.3fs'
            logging.data(msg % (self.loggingId, self.fileOnset,
                                self.duration))
        if not filename:
            onsettime = '-%d' % self.fileOnset + ms[1:]
            self.savedFile = onsettime.join(
                os.path.splitext(self.wavOutFilename))
        else:
            self.savedFile = os.path.abspath(filename)
            if not self.savedFile.endswith('.wav'):
                self.savedFile += '.wav'

        t0 = core.getTime()
        self.recorder.run(self.savedFile, self.duration, **self.options)

        self.rate = sound.backend.pyoSndServer.getSamplingRate()
        if block:
            core.wait(self.duration, 0)
            if log and self.autoLog:
                msg = '%s: Record: stop. %.3f, capture %.3fs (est)'
                logging.exp(msg % (self.loggingId, core.getTime(),
                                   core.getTime() - t0))
            while self.recorder.running:
                core.wait(.001, 0)
        else:
            if log and self.autoLog:
                msg = '%s: Record: return immediately, no blocking'
                logging.exp(msg % (self.loggingId))

        return self.savedFile
开发者ID:dgfitch,项目名称:psychopy,代码行数:41,代码来源:microphone.py


示例17: _onPygletMousePress

def _onPygletMousePress(x,y, button, modifiers, emulated=False):
    """button left=1, middle=2, right=4;
    """
    global mouseButtons, mouseClick, mouseTimes
    if emulated:
        label = 'Emulated'
    else:
        label = ''
    if button & LEFT:
        mouseButtons[0]=1
        mouseTimes[0]= psychopy.clock.getTime()-mouseClick[0].getLastResetTime()
        label += ' Left'
    if button & MIDDLE:
        mouseButtons[1]=1
        mouseTimes[1]= psychopy.clock.getTime()-mouseClick[1].getLastResetTime()
        label += ' Middle'
    if button & RIGHT:
        mouseButtons[2]=1
        mouseTimes[2]= psychopy.clock.getTime()-mouseClick[2].getLastResetTime()
        label += ' Right'
    logging.data("Mouse: %s button down, pos=(%i,%i)" %(label.strip(), x,y))
开发者ID:muzmar,项目名称:psychopy,代码行数:21,代码来源:event.py


示例18: waitKeys

def waitKeys(maxWait = None, keyList=None):
    """
    Halts everything (including drawing) while awaiting
    input from keyboard. Then returns *list* of keys pressed. Implicitly clears
    keyboard, so any preceding keypresses will be lost.

    Optional arguments specify maximum wait period and which keys to wait for.

    Returns None if times out.
    """

    #NB pygame.event does have a wait() function that will
    #do this and maybe leave more cpu idle time?
    key=None
    clearEvents('keyboard')#so that we only take presses from here onwards.
    if maxWait!=None and keyList!=None:
        #check keylist AND timer
        timer = psychopy.core.Clock()
        while key==None and timer.getTime()<maxWait:
            if havePyglet:
                wins = pyglet.window.get_platform().get_default_display().get_windows()
                for win in wins: win.dispatch_events()#pump events on pyglet windows
            keys = getKeys()
            #check if we got a key in list
            if len(keys)>0 and (keys[0] in keyList):
                key = keys[0]

    elif keyList!=None:
        #check the keyList each time there's a press
        while key==None:
            if havePyglet:
                wins = pyglet.window.get_platform().get_default_display().get_windows()
                for win in wins: win.dispatch_events()#pump events on pyglet windows
            keys = getKeys()
            #check if we got a key in list
            if len(keys)>0 and (keys[0] in keyList):
                key = keys[0]

    elif maxWait!=None:
        #onyl wait for the maxWait
        timer = psychopy.core.Clock()
        while key==None and timer.getTime()<maxWait:
            if havePyglet:
                wins = pyglet.window.get_platform().get_default_display().get_windows()
                for win in wins: win.dispatch_events()#pump events on pyglet windows
            keys = getKeys()
            #check if we got a key in list
            if len(keys)>0:
                key = keys[0]

    else: #simply take the first key we get
        while key==None:
            if havePyglet:
                wins = pyglet.window.get_platform().get_default_display().get_windows()
                for win in wins: win.dispatch_events()#pump events on pyglet windows
            keys = getKeys()
            #check if we got a key in list
            if len(keys)>0:
                key = keys[0]

    #after the wait period or received a valid keypress
    if key:
        logging.data("Key pressed: %s" %key)
        return [key]#need to convert back to a list
    else:
        return None #no keypress in period
开发者ID:jamesmcm,项目名称:psychopy,代码行数:66,代码来源:event.py


示例19: popns

#create a window to draw in
myWin =visual.Window((600,600), allowGUI=False,
    bitsMode=None, units='norm', winType='pyglet')

#INITIALISE SOME STIMULI
dotPatch =visual.DotStim(myWin, rgb=(1.0,1.0,1.0), dir=270,
    nDots=100, fieldShape='circle', fieldPos=(0.0,0.0),fieldSize=1,
    dotLife=5, #number of frames for each dot to be drawn
    signalDots='same', #are the signal and noise dots 'different' or 'same' popns (see Scase et al)
    noiseDots='direction', #do the noise dots follow random- 'walk', 'direction', or 'position'
    speed=0.01, coherence=0.9)
message =visual.TextStim(myWin,text='Hit Q to quit',
    pos=(0,-0.5))
trialClock =core.Clock()
myWin.setRecordFrameIntervals()
n=0
while True:#quits after 20 secs
    n+=1
    dotPatch.draw()
    message.draw()
    myWin.flip()#redraw the buffer
    for n in range(10):
        logging.info('%i info' %n)
    #handle key presses each frame
    for key in event.getKeys():
        if key in ['escape','q']:
            logging.data('final fps = %.3f' % myWin.fps())
            myWin.close()
            core.quit()
    event.clearEvents()#keep the event buffer from overflowing
开发者ID:RSharman,项目名称:psychopy,代码行数:30,代码来源:testLoggingDelays.py


示例20: range

     button_resp.frameNStart = frameN  # exact frame index
     win.timeOnFlip(button_resp, 'tStartRefresh')  # time at next scr refresh
     button_resp.status = STARTED
     # joyButtons checking is just starting
     win.callOnFlip(button_resp.clock.reset)  # t=0 on next screen flip
 if button_resp.status == STARTED:
     button_resp.newButtonState = button_resp.device.getAllButtons()[:]
     button_resp.pressedButtons = []
     button_resp.releasedButtons = []
     button_resp.newPressedButtons = []
     if button_resp.newButtonState != button_resp.oldButtonState:
         button_resp.pressedButtons = [i for i in range(button_resp.numButtons) if button_resp.newButtonState[i] and not button_resp.oldButtonState[i]]
         button_resp.releasedButtons = [i for i in range(button_resp.numButtons) if not button_resp.newButtonState[i] and button_resp.oldButtonState[i]]
         button_resp.oldButtonState = button_resp.newButtonState
         button_resp.newPressedButtons = [i for i in [0, 1, 2, 3, 4] if i in button_resp.pressedButtons]
         [logging.data("joystick_{}_button: {}".format(button_resp.device_number,i)) for i in button_resp.pressedButtons]
     theseKeys = button_resp.newPressedButtons
     if len(theseKeys) > 0:  # at least one key was pressed
         button_resp.keys = theseKeys[-1]  # just the last key pressed
         button_resp.rt = button_resp.clock.getTime()
         # a response ends the routine
         continueRoutine = False
 
 # check for quit (typically the Esc key)
 if endExpNow or keyboard.Keyboard().getKeys(keyList=["escape"]):
     core.quit()
 
 # check if all components have finished
 if not continueRoutine:  # a component has requested a forced-end of Routine
     break
 continueRoutine = False  # will revert to True if at least one component still running
开发者ID:isolver,项目名称:psychopy,代码行数:31,代码来源:correctJoyButtonsComponent.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logging.debug函数代码示例发布时间:2022-05-25
下一篇:
Python log.warning函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap