Image_button functions
class ImageButton
The image_button widget is a clickable image.
Example (OpenSesame script):
widget 0 0 1 1 image_button path='5.png' var='response'
Example (Python):
form = Form()
# The full path to the image needs to be provided.
# self.experiment.pool can be used to retrieve the full path
# to an image in the file pool.
image_button = ImageButton(path=pool['5.png'], var='response')
form.set_widget(image_button, (0,0))
form._exec()
- class ImageButton
- function ImageButton.__init__(form, path=None, adjust=True, frame=False, image_id=None, var=None)
 - function ImageButton._init_canvas_elements()
 - function ImageButton._update()
 - function ImageButton._update_frame(rect=None, style=u'normal')
 - function ImageButton.coroutine()
 - function ImageButton.on_key_press(key)
 - function ImageButton.on_mouse_click(pos)
 - function ImageButton.set_rect(rect)
 - function ImageButton.set_var(val, var=None)
 
 
function ImageButton.__init__(form, path=None, adjust=True, frame=False, image_id=None, var=None)
Constructor to create a new ImageButton object. You do not
generally call this constructor directly, but use the
ImageButton() factory function, which is described here:
/python/common/.
Arguments:
form-- The parent form.- Type: form
 
Keywords:
path-- The full path to the image. To show an image from the file pool, you need to first useexperiment.get_fileto determine the full path to the image.- Type: str, unicode, NoneType
 - Default: None
 
adjust-- Indicates whether the image should be scaled according to the size of the widget.- Type: bool
 - Default: True
 
frame-- Indicates whether a frame should be drawn around the widget.- Type: bool
 - Default: False
 
image_id-- An id to identify the image when it is clicked. IfNone, the path to the image is used as id.- Type: str, unicode, NoneType
 - Default: None
 
var-- The name of the experimental variable that should be used to log the widget status.- Type: str, unicode, NoneType
 - Default: None
 
function ImageButton._init_canvas_elements()
Initializes all canvas elements.
function ImageButton._update()
Draws the widget.
function ImageButton._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 ImageButton.coroutine()
Implements the interaction. This can be overridden to implement more complicated keyboard/ mouse interactions.
function ImageButton.on_key_press(key)
Is called whenever the widget is focused and the users enters a key.
Arguments:
key-- A key- Type: str
 
function ImageButton.on_mouse_click(pos)
Is called whenever the user clicks on the widget. Returns the image_id or the path to the image if no image_id has been specified.
Arguments:
pos-- An (x, y) coordinate tuple.- Type: tuple
 
function ImageButton.set_rect(rect)
Sets the widget geometry.
Arguments:
rect-- A (left, top, width, height) tuple.- Type: tuple
 
function ImageButton.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
 



