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(self.experiment)
button = widgets.button(form, text='Click me!', frame=True, center=True,
var='response')
form.set_widget(button, (0,0))
form._exec()
Function list:
- function button.__init__(form, var=None, text=u’button’, frame=True, center=True)
- function button.draw_frame(style=u’normal’, rect=None)
- function button.draw_text(text, html=True)
- function button.on_mouse_click(pos)
- function button.render()
- function button.set_rect(rect)
- function button.set_var(val, var=None)
function button.__init__(form, var=None, text=u’button’, frame=True, center=True)
Constructor.
Arguments:
form
– The parent form.- Type: form
Keywords:
text
– Button text.- Type: str, unicode
- Default: u’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 widget status.- Type: str, unicode, NoneType
- Default: None
function button.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 orNone
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 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