expyriment.io.TouchScreenButtonBox¶
-
class
expyriment.io.
TouchScreenButtonBox
(button_fields, stimuli=[], background_stimulus=None)¶ A class implementing a TouchScreenButtonBox.
-
__init__
(button_fields, stimuli=[], background_stimulus=None)¶ Initialize a touchscreen button box.
Parameters: button_fields : visual Expyriment stimulus or list of stimuli
The button fields defines the area on which a click action will be registered.
stimuli : visual Expyriment stimulus or list of stimuli, optional
Additional visual stimuli that will be presented together with the button fields. Stimuli are plotted on top of the button_fields.
background_stimulus : visual Expyriment stimulus, optional
The background stimulus on which the touschscreen button fields are presented. Importantly, background_stimulus has to have size of the screen.
Notes
Every visual Expyriment stimulus can serve as a touchscreen button field. If the TouchScreenButtonBox is presented, it can be checked for events using the methods ‘check’ and ‘wait’.
Add a touchscreen button fields.
Parameters: button_field : visual Expyriment stimulus
-
add_stimulus
(stimulus)¶ Add additional stimulus
The added stimulus will be presented together with the button fields.
Parameters: stimulus : visual Expyriment stimulus
-
background_stimulus
¶ Getter of background stimulus.
Background stimulus, on which the button fields and the additional stimuli will be presented. (visual Expyriment stimuli)
getter of button fields (list of visual Expyriment stimuli)
-
check
(button_fields=None)¶ Check if a button field is clicked.
Parameters: button_fields : Expyriment stimulus or list of stimuli, optional
The button fields that will be checked for.
Returns: pressed_button_field : Expyriment stimulus or list of stimuli, optional
The button fields that will be checked for.
touch_time : integer
The time when the button was touched. Function might return delayed, because button field comparison (after touch) takes time. The return time is most accurate.
Notes
Don’t forget to show the TouchScreenButtonBox.
-
clear_event_buffer
()¶ Clear the event buffer of the touchscreen/mouse input device.
-
create
()¶ Create the touchscreen buttonbox.
Prepares the button fields and additional stimuli for fast presentation.
-
last_touch_position
¶ getter for the last touch position (x,y)
-
logging
¶ Getter for logging.
-
set_logging
(onoff)¶ Set logging of this object on or off
Parameters: onoff : bool
set logging on (True) or off (False)
Notes
See also design.experiment.set_log_level fur further information about event logging.
-
show
()¶ Present touchscreen buttons.
-
stimuli
¶ getter of additional stimuli (list of visual Expyriment stimuli)
-
wait
(duration=None, button_fields=None, callback_function=None, process_control_events=True)¶ Wait for a touchscreen button box click.
Parameters: button_fields : Expyriment stimulus or list of stimuli, optional
The button fields that will be checked for.
duration : int, optional
maximal time to wait in ms
callback_function : function, optional
function to repeatedly execute during waiting loop
process_control_events : bool, optional
process
io.Keyboard.process_control_keys()
andio.Mouse.process_quit_event()
(default = True)Returns: pressed_button_field : Expyriment stimulus or None
the button field defined by a stimulus that has been pressed
rt : int
reaction time
See also
design.experiment.register_wait_callback_function
Notes
This will also by default process control events (quit and pause). Thus, keyboard events will be cleared from the cue and cannot be received by a Keyboard().check() anymore!
Don’t forget to show the TouchScreenButtonBox.
-