Supported by Supported by Advertisement

Text_input functions

class text_input

The text_input widget allows the participant to enter multi-character responses. (This widget has no relation to the text_input plug-in, which was created before forms where added to OpenSesame.)

Example (OpenSesame script):

widget 0 0 1 1 text_input var='response' return_accepts='yes'

Example (Python):

from libopensesame import widgets
form = widgets.form(exp)
text_input = widgets.text_input(form, var='response',
        return_accepts=True)
form.set_widget(text_input, (0,0))
form._exec()

function text_input.__init__(form, text=u'', frame=True, center=False, stub=u'Type here ...', return_accepts=False, var=None)

Constructor.

Arguments:

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

Keywords:

  • text -- The text to start with.
    • Type: str, unicode
    • Default: ''
  • frame -- Indicates whether a frame should be drawn around the widget.
    • Type: bool
    • Default: True
  • center -- Indicates whether the text should be centered.
    • Type: bool
    • Default: False
  • stub -- A text string that should be shown whenever the user has not entered any text.
    • Type: str, unicode
    • Default: 'Type here ...'
  • return_accepts -- Indicates whether a return press should accept and close the form.
    • Type: bool
    • Default: False
  • var -- The name of the experimental variable that should be used to log t

function text_input.draw_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 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 text_input.draw_text(text, html=True)

Draws text inside the widget.

Arguments:

  • text -- The text to draw.
    • Type: str, unicode

Keywords:

  • html -- Indicates whether HTML should be parsed.
    • Type: bool
    • Default: True

function text_input.on_mouse_click(pos)

Is called whenever the user clicks on the widget. Activates the text input for typing text.

Arguments:

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

function text_input.render()

Draws the widget.

function text_input.set_rect(rect)

Sets the widget geometry.

Arguments:

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

function text_input.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