Rating_scale functions
class RatingScale
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):
form = Form()
label = Label(text='I like fluffy kittens')
rating_scale = RatingScale(nodes=['Agree', "Don't know",
'Disagree'], var='response')
form.set_widget(label, (0,0))
form.set_widget(rating_scale, (0,1))
form._exec()
- class RatingScale
- function RatingScale.__init__(form, nodes=5, click_accepts=False, orientation=u'horizontal', var=None, default=None)
- function RatingScale._init_canvas_elements()
- function RatingScale._update()
- function RatingScale._update_frame(rect=None, style=u'normal')
- function RatingScale.coroutine()
- function RatingScale.on_key_press(key)
- function RatingScale.on_mouse_click(pos)
- function RatingScale.set_rect(rect)
- function RatingScale.set_value(val)
- function RatingScale.set_var(val, var=None)
function RatingScale.__init__(form, nodes=5, click_accepts=False, orientation=u'horizontal', var=None, default=None)
Constructor to create a new RatingScale object. You do not
generally call this constructor directly, but use the
RatingScale() factory function, which is described here:
/python/common/.
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: '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, orNoneto select no node. The value corresponds to the node number, where 0 is the first node.- Type: int, NoneType
- Default: None
function RatingScale._init_canvas_elements()
Initializes all canvas elements.
function RatingScale._update()
Draws the widget.
function RatingScale._update_frame(rect=None, style=u'normal')
Draws a simple frame around the widget.
Keywords:
rect-- A (left, top, width, height) tuple for the frame geometry orNoneto 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 RatingScale.coroutine()
Implements the interaction. This can be overridden to implement more complicated keyboard/ mouse interactions.
function RatingScale.on_key_press(key)
Is called whenever the widget is focused and the users enters a key.
Arguments:
key-- A key- Type: str
function RatingScale.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 RatingScale.set_rect(rect)
Sets the widget geometry.
Arguments:
rect-- A (left, top, width, height) tuple.- Type: tuple
function RatingScale.set_value(val)
Sets the rating scale value.
Arguments:
val-- The value.- Type: int
function RatingScale.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



