Skip to content

text_box

pdwidgets.widgets.text_box

Read-only formatted text display.

TextBox(parent, x=0, y=0, w=None, h=None, align=None, align_to=None, fg=None, bg=None, visible=True, value=None, padding=None, format='', text_height=TEXT_SIZE.LARGE, scale=1, inverted=False, font_data=None)

Bases: Widget

Read-only formatted text display.

Initialize a TextBox widget to display formatted text.

Parameters:

Name Type Description Default
parent Widget

The parent widget or screen that contains this text box.

required
x int

The x-coordinate of the text box.

0
y int

The y-coordinate of the text box.

0
w int

The width of the text box.

None
h int

The height of the text box.

None
align int

The alignment of the text box.

None
align_to Widget

The widget to align to.

None
fg int

The color of the text.

None
bg int

The background color of the text box.

None
visible bool

The visibility of the text box.

True
value str

The text content of the text box.

None
padding tuple

The padding on each side of the text box.

None
format str

The format string for the text.

''
text_height int

The height of the text (default is TEXT_SIZE.LARGE).

LARGE
scale int

The scale of the text (default is 1).

1
inverted bool

The inversion of the text (default is False).

False
font_data str

The font file to use for the text.

None
Usage

text_box = TextBox(screen, value="Hello, world!", format="{:>20}", text_height=TEXT_SIZE.LARGE)

char_height property

Rendered character height in pixels.

char_width property

Rendered character width in pixels.

draw(_=None)

Draw the label's text on the screen, using absolute coordinates.