Пример #1
0
    def __init__(self, form, nodes=5, click_accepts=False, orientation=u"horizontal", var=None, default=None):

        """
		desc:
			Constructor.

		arguments:
			form:
				desc:	The parent form.
				type:	form

		keywords:
			nodes:
				desc:	The number of nodes or a list of node identifiers (e.g.,
						['yes', 'no', 'maybe']. If a list is passed the rating
						scale will have labels, otherwise it will just have
						boxes.
				type:	[int, list]
			click_accepts:
				desc:	Indicates whether the form should close when a value
						is selected.
				type:	bool
			orientation:
				desc:	|
						'horizontal' indicates a horizontally oriented rating
						scale, 'vertical' indicates a vertically oriented rating
						scale.
				type:	[str, unicode]
			var:
				desc:	The name of the experimental variable that should be
						used to log the widget status. The value that is logged
						is the number of the node that was selected, with the
						first node being 0. If no nodes were selected, the value
						is 'None'. For more information about the use of
						response variables in forms, see the form documentation
						page.
				type:	[str, unicode, NoneType]
			default:
				desc:	The node that is selected by default, or `None` to
						select no node. The value corresponds to the node
						number, where 0 is the first node.
				type:	[int, NoneType]
		"""

        if isinstance(click_accepts, basestring):
            click_accepts = click_accepts == u"yes"

        widget.__init__(self, form)
        self.type = u"rating_scale"
        self.click_accepts = click_accepts
        self.pos_list = []
        self.var = var
        self.orientation = orientation
        if type(nodes) == int:
            self.nodes = [u""] * nodes
        elif isinstance(nodes, basestring):
            self.nodes = nodes.split(u";")
        else:
            self.nodes = nodes
        self.set_value(default)
Пример #2
0
	def __init__(self, form, path=None, adjust=True, frame=False):

		"""
		desc:
			Constructor.

		arguments:
			form:
				desc:	The parent form.
				type:	form

		keywords:
			path:
				desc:	The full path to the image. To show an image from the
						file pool, you need to first use `experiment.get_file`
						to determine the full path to the image.
				type:	[str, unicode, NoneType]
			adjust:
				desc:	Indicates whether the image should be scaled according
						to the size of the widget.
				type:	bool
			frame:
				desc:	Indicates whether a frame should be drawn around the
						widget.
				type:	bool
		"""

		if type(adjust) != bool:
			adjust = adjust == u'yes'
		if type(frame) != bool:
			frame = frame == u'yes'

		widget.__init__(self, form)
		self.adjust = adjust
		self.frame = frame
		self.path = path
		self.type = u'image'
Пример #3
0
	def __init__(self, form, text=u'label', frame=False, center=True):

		"""
		desc:
			Constructor.

		arguments:
			form:
				desc:	The parent form.
				type:	form

		keywords:
			text:
				desc:	The label text.
				type:	[str, unicode]
			frame:
				desc:	Indicates whether a frame should be drawn around the
						widget.
				type:	bool
			center:
				desc:	Indicates whether the text should be centerd.
				type:	bool
		"""

		if type(frame) != bool:
			frame = frame == u'yes'
		if type(center) != bool:
			center = center == u'yes'

		widget.__init__(self, form)
		self.type = u'label'
		self.text = text
		self.frame = frame
		self.center = center
		self.x_pad = 8
		self.y_pad = 8
		self.tab_str = u'    ' # Replace tab characters by four spaces
Пример #4
0
	def __init__(self, form, path=None, adjust=True, frame=False):

		"""
		desc:
			Constructor.

		arguments:
			form:
				desc:	The parent form.
				type:	form

		keywords:
			path:
				desc:	The full path to the image. To show an image from the
						file pool, you need to first use `experiment.get_file`
						to determine the full path to the image.
				type:	[str, unicode, NoneType]
			adjust:
				desc:	Indicates whether the image should be scaled according
						to the size of the widget.
				type:	bool
			frame:
				desc:	Indicates whether a frame should be drawn around the
						widget.
				type:	bool
		"""

		if type(adjust) != bool:
			adjust = adjust == u'yes'
		if type(frame) != bool:
			frame = frame == u'yes'

		widget.__init__(self, form)
		self.adjust = adjust
		self.frame = frame
		self.path = path
		self.type = u'image'
Пример #5
0
    def __init__(self,
                 form,
                 nodes=5,
                 click_accepts=False,
                 orientation=u'horizontal',
                 var=None,
                 default=None):
        """
		desc:
			Constructor.

		arguments:
			form:
				desc:	The parent form.
				type:	form

		keywords:
			nodes:
				desc:	The number of nodes or a list of node identifiers (e.g.,
						['yes', 'no', 'maybe']. If a list is passed the rating
						scale will have labels, otherwise it will just have
						boxes.
				type:	[int, list]
			click_accepts:
				desc:	Indicates whether the form should close when a value
						is selected.
				type:	bool
			orientation:
				desc:	|
						'horizontal' indicates a horizontally oriented rating
						scale, 'vertical' indicates a vertically oriented rating
						scale.
				type:	[str, unicode]
			var:
				desc:	The name of the experimental variable that should be
						used to log the widget status. The value that is logged
						is the number of the node that was selected, with the
						first node being 0. If no nodes were selected, the value
						is 'None'. For more information about the use of
						response variables in forms, see the form documentation
						page.
				type:	[str, unicode, NoneType]
			default:
				desc:	The node that is selected by default, or `None` to
						select no node. The value corresponds to the node
						number, where 0 is the first node.
				type:	[int, NoneType]
		"""

        if isinstance(click_accepts, basestring):
            click_accepts = click_accepts == u'yes'

        widget.__init__(self, form)
        self.type = u'rating_scale'
        self.click_accepts = click_accepts
        self.pos_list = []
        self.var = var
        self.orientation = orientation
        if type(nodes) == int:
            self.nodes = [u''] * nodes
        elif isinstance(nodes, basestring):
            self.nodes = nodes.split(u';')
        else:
            self.nodes = nodes
        self.set_value(default)