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

OpenSesame 3.0.0 will bring amazing new features! Curious? Take it for a test spin, and help us iron out the kinks.

Image functions

class image

The image widget is used to display a non-interactive image.

Example (OpenSesame script):

widget 0 0 1 1 image path='5.png'

Example (Python):

from libopensesame import widgets
form = widgets.form(self.experiment)
# The full path to the image needs to be provided.
# self.experiment.get_file() can be used to retrieve the full path
# to an image in the file pool.
image = widgets.image(form, path=self.experiment.get_file('5.png'))
form.set_widget(image, (0,0))
form._exec()

Function list:

function image.__init__(form, path=None, frame=False, adjust=True)

Constructor.

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 use experiment.get_file to 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

function image.draw_frame(style=u’normal’, rect=None)

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: u’normal’

function image.on_mouse_click(pos)

Is called whenever the user clicks on the widget.

Arguments:

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

function image.render()

Draws the widget.

function image.set_rect(rect)

Sets the widget geometry.

Arguments:

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

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