Text_input functions
class TextInput
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):
form = Form()
text_input = TextInput(var='response', return_accepts=True)
form.set_widget(text_input, (0,0))
form._exec()
- class TextInput
- function TextInput.__init__(form, text=u'', frame=True, center=False, stub=u'Type here ...', return_accepts=False, var=None, key_filter=None)
- function TextInput._init_canvas_elements()
- function TextInput._update()
- function TextInput._update_frame(rect=None, style=u'normal')
- function TextInput._update_text(text)
- function TextInput.coroutine()
- function TextInput.on_key_press(key)
- function TextInput.on_mouse_click(pos)
- function TextInput.set_rect(rect)
- function TextInput.set_var(val, var=None)
function TextInput.__init__(form, text=u'', frame=True, center=False, stub=u'Type here ...', return_accepts=False, var=None, key_filter=None)
Constructor to create a new TextInput object. You do not generally
call this constructor directly, but use the TextInput() factory
function, which is described here: /python/common/.
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 the widget status.- Type: str, unicode, NoneType
- Default: None
key_filter-- A function that takes a key as a single argument and return True if the key should be accepted and False otherwise. This can also filter out keys such as return and backspace, but not Escape.- Type: FunctionType, NoneType
- Default: None
function TextInput._init_canvas_elements()
Initializes all canvas elements.
function TextInput._update()
Draws the widget.
function TextInput._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 TextInput._update_text(text)
Draws text inside the widget.
Arguments:
text-- The text to draw.- Type: str, unicode
function TextInput.coroutine()
Implements the interaction.
function TextInput.on_key_press(key)
Is called whenever the widget is focused and the users enters a key.
Arguments:
key-- A key- Type: str
function TextInput.on_mouse_click(pos)
Is called whenever the user clicks on the widget.
Arguments:
pos-- An (x, y) coordinates tuple.- Type: tuple
function TextInput.set_rect(rect)
Sets the widget geometry.
Arguments:
rect-- A (left, top, width, height) tuple.- Type: tuple
function TextInput.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



