Supported by Supported by

Button functions

class button

The button widget is a clickable text string, by default surrounded by a button-like frame.

Example (OpenSesame script):

widget 0 0 1 1 button text='Click me!' center='yes' frame='yes' var='response'

Defining a button widget with Python inline code:

Example (Python):

from libopensesame import widgets
form = widgets.form(exp)
button = widgets.button(form, text='Click me!', frame=True, center=True,
        var='response')
form.set_widget(button, (0,0))
form._exec()

function button.__init__(form, text=u'button', frame=True, center=True, var=None)

Constructor.

Arguments:

  • form -- The parent form.
    • Type: form

Keywords:

  • text -- Button text.
    • Type: str, unicode
    • Default: 'button'
  • 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: True
  • var -- The name of the experimental variable that should be used to log the w

function button.draw_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 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: 'normal'

function button.draw_text(text, html=True)

Draws text inside the widget.

Arguments:

  • text -- The text to draw.
    • Type: str, unicode

Keywords:

  • html -- Indicates whether HTML should be parsed.
    • Type: bool
    • Default: True

function button.on_mouse_click(pos)

Is called when the user clicks on the button. Returns the button text.

Arguments:

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

Returns:

The button text.

  • Type: unicode

function button.render()

Draws the widget.

function button.set_rect(rect)

Sets the widget geometry.

Arguments:

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

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