You are viewing unmaintained documentation for an older version of OpenSesame. Click here to view the current documentation. Your version of OpenSesame: Language:

OpenSesame 3.0.0 will bring amazing new features! Curious? Take it for a test spin, and help us iron out the kinks.

Rating_scale functions

class rating_scale

The rating_scale widget is a horizontally aligned series of checkable boxes (nodes), optionally with a label attached to each node.

Example (OpenSesame script):

widget 0 0 1 1 label text="I like fluffy kittens"
widget 0 1 1 1 rating_scale var="response" nodes="Agree;Don't know;Disagree"

Example (OpenSesame script):

from libopensesame import widgets
form = widgets.form(self.experiment)
label = widgets.label(form, text='I like fluffy kittens')
rating_scale = widgets.rating_scale(form, nodes=['Agree', "Don't know",
        'Disagree'], var='response')
form.set_widget(label, (0,0))
form.set_widget(rating_scale, (0,1))
form._exec()

Function list:

function rating_scale.__init__(form, var=None, default=None, nodes=5, orientation=u’horizontal’, click_accepts=False)

Constructor.

Arguments:

  • form – The parent form.
    • Type: form

Keywords:

  • nodes – 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
    • Default: 5
  • click_accepts – Indicates whether the form should close when a value is selected.
    • Type: bool
    • Default: False
  • orientation – ‘horizontal’ indicates a horizontally oriented rating scale, ‘vertical’ indicates a vertically oriented rating scale.
    • Type: str, unicode
    • Default: u’horizontal’
  • var – 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: None
  • default – 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
    • Default: None

function rating_scale.draw_frame(style=u’normal’, rect=None)

Draws a simple frame around the widget.

Keywords:

  • rect – A (left, top, width, height) tuple for the frame geometry or None to use the widget geometry.
    • Type: tuple, NoneType
    • Default: None
  • style – A visual style. Should be ‘normal’, ‘active’, or ‘light’.
    • Type: str, unicode
    • Default: u’normal’

function rating_scale.on_mouse_click(pos)

Is called whenever the user clicks on the widget. Selects the correct value from the scale and optionally closes the form.

Arguments:

  • pos – An (x, y) coordinates tuple.
    • Type: tuple

function rating_scale.render()

Draws the widget.

function rating_scale.set_rect(rect)

Sets the widget geometry.

Arguments:

  • rect – A (left, top, width, height) tuple.
    • Type: tuple

function rating_scale.set_value(val)

Sets the rating scale value.

Arguments:

  • val – The value.
    • Type: int

function rating_scale.set_var(val, var=None)

Sets an experimental variable.

Arguments:

  • val – A value.

Keywords:

  • var – A variable name, or None to use widget default.
    • Type: str, unicode, NoneType
    • Default: None