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

Python attributetools.setAttribute函数代码示例

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

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



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

示例1: _set

    def _set(self, attrib, val, op='', log=None):
        """Use this to set attributes of your stimulus after initialising it.

        :Parameters:

        attrib : a string naming any of the attributes of the stimulus (set during init)
        val : the value to be used in the operation on the attrib
        op : a string representing the operation to be performed (optional) most maths operators apply ('+','-','*'...)

        examples::

            myStim.set('rgb',0) #will simply set all guns to zero (black)
            myStim.set('rgb',0.5,'+') #will increment all 3 guns by 0.5
            myStim.set('rgb',(1.0,0.5,0.5),'*') # will keep the red gun the same and halve the others

        """
        #format the input value as float vectors
        if type(val) in [tuple,list]:
            val=numpy.array(val,float)

        #change the attribute as requested
        setAttribute(self, attrib, val, log, op)

        #update the actual coherence for the requested coherence and nDots
        if attrib in ['nDots','coherence']:
            self.coherence=round(self.coherence*self.nDots)/self.nDots
开发者ID:hm0612,项目名称:psychopy,代码行数:26,代码来源:dot.py


示例2: setOris

    def setOris(self, value, operation='', log=None):
        """Usually you can use 'stim.attribute = value' syntax instead,
        but use this method if you need to suppress the log message.
        """

        # call attributeSetter
        setAttribute(self, 'oris', value, log, operation)
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:7,代码来源:elementarray.py


示例3: setPhases

 def setPhases(self, value, operation="", log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message.
     """
     # in the case of Nx1 list/array, setAttribute would fail if not this:
     value = self._makeNx2(value)
     setAttribute(self, "phases", value, log, operation)  # call attributeSetter
开发者ID:neuroidss,项目名称:psychopy,代码行数:7,代码来源:elementarray.py


示例4: setAutoDraw

    def setAutoDraw(self, val, log=None):
        """Add or remove a stimulus from the list of stimuli that will be
        automatically drawn on each flip

        :parameters:
            - val: True/False
                True to add the stimulus to the draw list, False to remove it
        """
        if val:
            self.play(log=False)  # set to play in case stopped
        else:
            self.pause(log=False)
        #add to drawing list and update status
        setAttribute(self, 'autoDraw', val, log)
开发者ID:papr,项目名称:psychopy,代码行数:14,代码来源:movie3.py


示例5: _set

    def _set(self, attrib, val, op='', log=True):
        """Deprecated. Use methods specific to the parameter you want to set.

        e.g. ::

             stim.pos = [3,2.5]
             stim.ori = 45
             stim.phase += 0.5

        NB this method does not flag the need for updates any more - that is
        done by specific methods as described above.
        """
        if op is None:
            op = ''
        # format the input value as float vectors
        if type(val) in (tuple, list):
            val = numpy.array(val, float)

        setAttribute(self, attrib, val, log, op)
开发者ID:dgfitch,项目名称:psychopy,代码行数:19,代码来源:simpleimage.py


示例6: setWidth

 def setWidth(self, width, operation='', log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     setAttribute(self, 'width', width, log, operation)
开发者ID:flipphillips,项目名称:psychopy,代码行数:5,代码来源:rect.py


示例7: setRadialPhase

 def setRadialPhase(self, value, operation='', log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     setAttribute(self, 'radialPhase', value, log,
                  operation)  # calls the attributeSetter
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:6,代码来源:radial.py


示例8: setRadius

 def setRadius(self, radius, log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message"""
     setAttribute(self, 'radius', radius, log)
开发者ID:hm0612,项目名称:psychopy,代码行数:4,代码来源:polygon.py


示例9: setEnd

 def setEnd(self, end, log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message.
     """
     setAttribute(self, 'end', end, log)
开发者ID:flipphillips,项目名称:psychopy,代码行数:5,代码来源:line.py


示例10: setFlipVert

 def setFlipVert(self, newVal=True, log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message"""
     setAttribute(self, 'flipVert', newVal, log)
开发者ID:jonathan-mejia,项目名称:psychopy,代码行数:4,代码来源:text.py


示例11: setHeight

 def setHeight(self, height, log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message. """
     setAttribute(self, 'height', height, log)
开发者ID:jonathan-mejia,项目名称:psychopy,代码行数:4,代码来源:text.py


示例12: setDepth

 def setDepth(self, newDepth, operation='', log=None):
     """DEPRECATED. Depth is now controlled simply by drawing order.
     """
     setAttribute(self, 'depth', newDepth, log, operation)
开发者ID:dgfitch,项目名称:psychopy,代码行数:4,代码来源:simpleimage.py


示例13: setColor

def setColor(obj, color, colorSpace=None, operation='',
             rgbAttrib='rgb',  # or 'fillRGB' etc
             colorAttrib='color',  # or 'fillColor' etc
             colorSpaceAttrib=None,  # e.g. 'colorSpace' or 'fillColorSpace'
             log=True):
    """Provides the workings needed by setColor, and can perform this for
    any arbitrary color type (e.g. fillColor,lineColor etc).

    OBS: log argument is deprecated - has no effect now.
    Logging should be done when setColor() is called.
    """

    # how this works:
    # rather than using obj.rgb=rgb this function uses setattr(obj,'rgb',rgb)
    # color represents the color in the native space
    # colorAttrib is the name that color will be assigned using
    #   setattr(obj,colorAttrib,color)
    # rgb is calculated from converting color
    # rgbAttrib is the attribute name that rgb is stored under,
    #   e.g. lineRGB for obj.lineRGB
    # colorSpace and takes name from colorAttrib+space e.g.
    # obj.lineRGBSpace=colorSpace

    if colorSpaceAttrib is None:
        colorSpaceAttrib = colorAttrib + 'Space'

    # Handle strings and returns immediately as operations, colorspace etc.
    # does not apply here.
    if isinstance(color, basestring):
        if operation not in ('', None):
            raise TypeError('Cannot do operations on named or hex color')
        if color.lower() in colors.colors255:
            # set rgb, color and colorSpace
            setattr(obj, rgbAttrib,
                    np.array(colors.colors255[color.lower()], float))
            obj.__dict__[colorSpaceAttrib] = 'named'  # e.g. 3rSpace='named'
            obj.__dict__[colorAttrib] = color  # e.g. obj.color='red'
            setTexIfNoShaders(obj)
            return
        elif color[0] == '#' or color[0:2] == '0x':
            # e.g. obj.rgb=[0,0,0]
            setattr(obj, rgbAttrib, np.array(colors.hex2rgb255(color)))
            obj.__dict__[colorSpaceAttrib] = 'hex'  # eg obj.colorSpace='hex'
            obj.__dict__[colorAttrib] = color  # eg Qr='#000000'
            setTexIfNoShaders(obj)
            return
        else:
            # we got a string, but it isn't in the list of named colors and
            # doesn't work as a hex
            raise AttributeError(
                "PsychoPy can't interpret the color string '%s'" % color)

    else:
        # If it wasn't a string, do check and conversion of scalars,
        # sequences and other stuff.
        color = val2array(color, length=3)  # enforces length 1 or 3

        if color is None:
            setattr(obj, rgbAttrib, None)  # e.g. obj.rgb=[0,0,0]
            obj.__dict__[colorSpaceAttrib] = None  # e.g. obj.colorSpace='hex'
            obj.__dict__[colorAttrib] = None  # e.g. obj.color='#000000'
            setTexIfNoShaders(obj)

    # at this point we have a numpy array of 3 vals
    # check if colorSpace is given and use obj.colorSpace if not
    if colorSpace is None:
        colorSpace = getattr(obj, colorSpaceAttrib)
        # using previous color space - if we got this far in the
        # _stColor function then we haven't been given a color name -
        # we don't know what color space to use.
        if colorSpace in ('named', 'hex'):
            logging.error("If you setColor with a numeric color value then"
                          " you need to specify a color space, e.g. "
                          "setColor([1,1,-1],'rgb'), unless you used a "
                          "numeric value previously in which case PsychoPy "
                          "will reuse that color space.)")
            return
    # check whether combining sensible colorSpaces (e.g. can't add things to
    # hex or named colors)
    if operation != '' and getattr(obj, colorSpaceAttrib) in ['named', 'hex']:
        msg = ("setColor() cannot combine ('%s') colors "
               "within 'named' or 'hex' color spaces")
        raise AttributeError(msg % operation)
    elif operation != '' and colorSpace != getattr(obj, colorSpaceAttrib):
        msg = ("setColor cannot combine ('%s') colors"
               " from different colorSpaces (%s,%s)")
        raise AttributeError(msg % (operation, obj.colorSpace, colorSpace))
    else:  # OK to update current color
        if colorSpace == 'named':
            # operations don't make sense for named
            obj.__dict__[colorAttrib] = color
        else:
            setAttribute(obj, colorAttrib, color, log=False,
                         operation=operation, stealth=True)
    # get window (for color conversions)
    if colorSpace in ['dkl', 'lms']:  # only needed for these spaces
        if hasattr(obj, 'dkl_rgb'):
            win = obj  # obj is probably a Window
        elif hasattr(obj, 'win'):
            win = obj.win  # obj is probably a Stimulus
#.........这里部分代码省略.........
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:101,代码来源:helpers.py


示例14: setSpeed

 def setSpeed(self, val, op='', log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     setAttribute(self, 'speed', val, log, op)
开发者ID:bergwiesel,项目名称:psychopy,代码行数:5,代码来源:dot.py


示例15: setFieldCoherence

 def setFieldCoherence(self, val, op='', log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     setAttribute(self, 'coherence', val, log, op)  # calls attributeSetter
开发者ID:bergwiesel,项目名称:psychopy,代码行数:5,代码来源:dot.py


示例16: setVolume

 def setVolume(self, value, operation="", log=None):
     """Sets the current volume of the sound (0.0:1.0)
     """
     attributetools.setAttribute(self, 'volume', value, log, operation)
     return value  # this is returned for historical reasons
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:5,代码来源:backend_pysound.py


示例17: setStart

 def setStart(self, start, log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     setAttribute(self, "start", start, log)
开发者ID:honeymustard33,项目名称:experiment_riskdetection,代码行数:5,代码来源:line.py


示例18: __init__


#.........这里部分代码省略.........
        unchanged shapes are as fast as usual. This includes ``pos``,
        ``opacity`` etc.

        The following attribute can only be set at initialization (see
        further down for a list of attributes which can be changed after
        initialization):

        **languageStyle**
            Apply settings to correctly display content from some languages
            that are written right-to-left. Currently there are three (case-
            insensitive) values for this parameter:
            ``'LTR'`` is the default, for typical left-to-right, Latin-style
            languages.
            ``'RTL'`` will correctly display text in right-to-left languages
             such as Hebrew. By applying the bidirectional algorithm, it
             allows mixing portions of left-to-right content (such as numbers
             or Latin script) within the string.
            ``'Arabic'`` applies the bidirectional algorithm but additionally
            will _reshape_ Arabic characters so they appear in the cursive,
            linked form that depends on neighbouring characters, rather than
            in their isolated form. May also be applied in other scripts,
            such as Farsi or Urdu, that use Arabic-style alphabets.

        :Parameters:

        """

        # what local vars are defined (these are the init params) for use by
        # __repr__
        self._initParams = dir()
        self._initParams.remove('self')

        """
        October 2018:
            In place to remove the deprecation warning for pyglet.font.Text.
            Temporary fix until pyglet.text.Label use is identical to pyglet.font.Text.
        """
        warnings.filterwarnings(message='.*text.Label*', action='ignore')

        super(TextStim, self).__init__(
            win, units=units, name=name, autoLog=False)

        if win.blendMode=='add':
            logging.warning("Pyglet text does not honor the Window setting "
                            "`blendMode='add'` so 'avg' will be used for the "
                            "text (but objects drawn after can be added)")
        self._needUpdate = True
        self._needVertexUpdate = True
        # use shaders if available by default, this is a good thing
        self.__dict__['useShaders'] = win._haveShaders
        self.__dict__['alignHoriz'] = alignHoriz
        self.__dict__['alignVert'] = alignVert
        self.__dict__['antialias'] = antialias
        self.__dict__['font'] = font
        self.__dict__['bold'] = bold
        self.__dict__['italic'] = italic
        # NB just a placeholder - real value set below
        self.__dict__['text'] = ''
        self.__dict__['depth'] = depth
        self.__dict__['ori'] = ori
        self.__dict__['flipHoriz'] = flipHoriz
        self.__dict__['flipVert'] = flipVert
        self.__dict__['languageStyle'] = languageStyle
        self._pygletTextObj = None
        self.__dict__['pos'] = numpy.array(pos, float)

        # generate the texture and list holders
        self._listID = GL.glGenLists(1)
        # pygame text needs a surface to render to:
        if not self.win.winType in ["pyglet", "glfw"]:
            self._texID = GL.GLuint()
            GL.glGenTextures(1, ctypes.byref(self._texID))

        # Color stuff
        self.colorSpace = colorSpace
        if rgb != None:
            msg = ("Use of rgb arguments to stimuli are deprecated. Please "
                   "use color and colorSpace args instead")
            logging.warning(msg)
            self.setColor(rgb, colorSpace='rgb', log=False)
        else:
            self.setColor(color, log=False)

        self.__dict__['fontFiles'] = []
        self.fontFiles = list(fontFiles)  # calls attributeSetter
        self.setHeight(height, log=False)  # calls setFont() at some point
        # calls attributeSetter without log
        setAttribute(self, 'wrapWidth', wrapWidth, log=False)
        self.__dict__['opacity'] = float(opacity)
        self.__dict__['contrast'] = float(contrast)
        # self.width and self._fontHeightPix get set with text and
        # calcSizeRendered is called
        self.setText(text, log=False)
        self._needUpdate = True

        # set autoLog now that params have been initialised
        wantLog = autoLog is None and self.win.autoLog
        self.__dict__['autoLog'] = autoLog or wantLog
        if self.autoLog:
            logging.exp("Created %s = %s" % (self.name, str(self)))
开发者ID:hoechenberger,项目名称:psychopy,代码行数:101,代码来源:text.py


示例19: setFieldSize

 def setFieldSize(self, value, operation='', log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message.
     """
     setAttribute(self, 'fieldSize', value, log, operation)
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:5,代码来源:elementarray.py


示例20: setOri

 def setOri(self, ori, needReset=True, log=None):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message.
     """
     self._needReset = needReset
     setAttribute(self, 'ori', ori, log)
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:6,代码来源:aperture.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python attributetools.setWithOperation函数代码示例发布时间:2022-05-25
下一篇:
Python attributetools.logAttrib函数代码示例发布时间: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