Textbox Component

This component can be used either to present text to the participant, or to allow free-text answers via the keyboard.


Everything in a PsychoPy® experiment needs a unique name. The name should contain only letters, numbers and underscores (no punctuation marks or spaces).

start :

The time that the stimulus should first appear. See Defining the onset/duration of components for details.

stop :

The duration for which the stimulus is presented. See Defining the onset/duration of components for details.


Whether this Textbox can be edited by the participant (text input) or not (static text).


Text to be shown


How should the stimulus look? Colour, borders, etc.

text colorcolor

See Color spaces

fill colorcolor

See Color spaces

border colorcolor

See Color spaces

color spacergb, dkl, lms, hsv

See Color spaces

border widthint | float

How wide should the line be? Width is specified in chosen spatial units, see Units for the window and stimuli

opacity :

Vary the transparency, from 0.0 = invisible to 1.0 = opaque


How should the stimulus be laid out? Padding, margins, size, position, etc.

flip horizontalbool

Whether to mirror-reverse the text horizontally (left-right mirroring)

flip verticalbool

Whether to mirror-reverse the text vertically (top-bottom mirroring)


The orientation of the stimulus in degrees.


The position of the centre of the stimulus, in the units specified by the stimulus or window

size(width, height)

Size of the stimulus on screen

spatial unitsdeg, cm, pix, norm, or inherit from window

See Units for the window and stimuli


How much space should there be between the box edge and the text?

anchorcenter, center-left, center-right, top-left, top-center, top-right, bottom-left, bottom-center, bottom-right

What point on the textbox should be anchored to its position? For example, if the position of the TextBox is (0, 0), should the middle of the textbox be in the middle of the screen, should its top left corner be in the middle of the screen, etc.?


Formatting text


What font should the text be set in? Can be a font installed on your computer, saved to the “fonts” folder in your PsychoPy® user folder or (if you are connected to the internet), a font from Google Fonts.

language styleLTR, RTL, Arabic

Should text be laid out from left to right (LTR), from right to left (RTL), or laid out like Arabic script?

letter heightinteger or float

The height of the characters in the given units of the stimulus/window. Note that nearly all actual letters will occupy a smaller space than this, depending on font, character, presence of accents etc. The width of the letters is determined by the aspect ratio of the font.

line spacingfloat

How tall should each line be, proportional to the size of the font?

See also

API reference for TextBox

Back to top