expyfun.visual.Text

class expyfun.visual.Text(ec, text, pos=(0, 0), color='white', font_name='Arial', font_size=24, height=None, width='auto', anchor_x='center', anchor_y='center', units='norm', wrap=False, attr=True)[source]

A text object.

Parameters:
ecinstance of ExperimentController

Parent EC.

textstr

The text to display.

posarray

2-element array consisting of X- and Y-position coordinates.

colormatplotlib Color

Color of the text.

font_namestr

Font to use.

font_sizefloat

Font size (points) to use.

heightfloat | None

Height of the text region. None will automatically allocate the necessary size.

widthfloat | None | str

Width (in pixels) of the text region. ‘auto’ will allocate 80% of the screen width, useful for instructions. None will automatically allocate sufficient space, but not that this disables text wrapping.

anchor_xstr

Horizontal text anchor (e.g., 'center').

anchor_ystr

Vertical text anchor (e.g., 'center').

unitsstr

Units to use. These will apply to all spatial aspects of the drawing. shape e.g. size, position. See check_units for options.

wrapbool

Whether or not the text will wrap to fit in screen, appropriate for multiline text. Inappropriate for text requiring precise positioning.

attrbool

Should the text be interpreted with pyglet’s decode_attributed method? This allows inline formatting for text color, e.g., 'This is {color (255, 0, 0, 255)}red text'. If attr=True, the values of font_name, font_size, and color are automatically prepended to text (though they will be overridden by any inline formatting within text itself).

Returns:
textinstance of Text

The text object.

draw()[source]

Draw the object to the display buffer

set_color(color)[source]

Set the text color

Parameters:
colormatplotlib Color | None

The color. Use None for no color.

Examples using expyfun.visual.Text

Display text with different formatting methods

Display text with different formatting methods

Use joystick controls

Use joystick controls

Video property control

Video property control