Label functions
class Label
The Label
widget is a non-interactive string of text.
Example (OpenSesame script):
widget 0 0 1 1 label text='My text'
Example (Python):
form = Form()
label = Label(text='My text')
form.set_widget(label, (0,0))
form._exec()
- class Label
- function Label.__init__(form, text=u'label', frame=False, center=True)
- function Label._init_canvas_elements()
- function Label._update()
- function Label._update_frame(rect=None, style=u'normal')
- function Label._update_text(text)
- function Label.coroutine()
- function Label.on_key_press(key)
- function Label.on_mouse_click(pos)
- function Label.set_rect(rect)
- function Label.set_var(val, var=None)
function Label.__init__(form, text=u'label', frame=False, center=True)
Constructor to create a new Label
object. You do not generally
call this constructor directly, but use the Label()
factory
function, which is described here: /python/common/.
Arguments:
form
-- The parent form.- Type: form
Keywords:
text
-- The label text.- Type: str, unicode
- Default: 'label'
frame
-- Indicates whether a frame should be drawn around the widget.- Type: bool
- Default: False
center
-- Indicates whether the text should be centerd.- Type: bool
- Default: True
function Label._init_canvas_elements()
Initializes all canvas elements.
function Label._update()
Draws the widget.
function Label._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 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: 'normal'
function Label._update_text(text)
Draws text inside the widget.
Arguments:
text
-- The text to draw.- Type: str, unicode
function Label.coroutine()
Implements the interaction. This can be overridden to implement more complicated keyboard/ mouse interactions.
function Label.on_key_press(key)
Is called whenever the widget is focused and the users enters a key.
Arguments:
key
-- A key- Type: str
function Label.on_mouse_click(pos)
Is called whenever the user clicks on the widget.
Arguments:
pos
-- An (x, y) coordinates tuple.- Type: tuple
function Label.set_rect(rect)
Sets the widget geometry.
Arguments:
rect
-- A (left, top, width, height) tuple.- Type: tuple
function Label.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