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

Test the next generation of OpenSesame: 2.9.0 Hesitant Heisenberg!

Text_input functions

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

Defining a text_input widget in OpenSesame script using the form_base plug-in:

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

Defining a text_input widget with Python inline code:

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

Function overview:
__init__
draw_frame
draw_text
on_mouse_click
render
set_rect
set_var

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.

Keyword arguments:
text → The text to start with (default=u'').
frame → Indicates whether a frame should be drawn around the widget
(default=False).
center → Indicates whether the text should be centered (default=False).
stub → A text string that should be shown whenever the user has not
entered any text (default=u'Type here ...').
return_accepts → Indicates whether a return press should accept and
close the form (default=False).
var → The name of the experimental variable that should be used to log
the widget status (default=None).
text_input.draw_frame(rect=None, style=u'normal')
Inherited from widget

Draws a simple frame around the widget.

Keyword arguments:
rect → A (left, top, width, height) tuple for the frame geometry or
None to use the widget geometry (default=None).
style → 'normal', 'active', 'light' (default='normal').
text_input.draw_text(text, html=True)
Inherited from label

Draws text in the widget.

Arguments:
text → The text to draw.

Keyword arguments:
html → Indicates whether HTML should be parsed (default=True).
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) tuple.
text_input.render()
Draws the widget.
text_input.set_rect(rect)
Inherited from widget

Sets the widget geometry.

Arguments:
rect → A (left, top, width, height) tuple.
text_input.set_var(val, var=None)
Inherited from widget

Sets an experimental variable.

Arguments:
val → A value.

Keyword arguments:
var → A variable name, or None to use widget default (default=None).