OpenSesame videos
Python videos

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(exp)
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))

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



  • form -- The parent form.
    • Type: form


  • 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: '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(rect=None, style=u'normal')

Draws a simple frame around the widget.


  • 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: '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.


  • 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.


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

function rating_scale.set_value(val)

Sets the rating scale value.


  • val -- The value.
    • Type: int

function rating_scale.set_var(val, var=None)

Sets an experimental variable.


  • val -- A value.


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