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'
. Ifattr=True
, the values offont_name
,font_size
, andcolor
are automatically prepended totext
(though they will be overridden by any inline formatting withintext
itself).
Methods
- Returns:
- textinstance of Text
The text object.
Examples using expyfun.visual.Text
#
Display text with different formatting methods