Actor > Textbox#
API Reference#
- class miniworlds.actors.texts.textbox.TextBox(position, width, height, **kwargs)[source]
A multi-line text box with fixed width and height.
Long lines are automatically word-wrapped to fit within the given width. Each line is rendered as a separate Text actor.
- Parameters:
position – Top-left position of the text box.
width – Width of the text box in pixels.
height – Maximum height of the text box in pixels.
text – Initial text to display (keyword argument).
font_size – Font size for all lines (keyword argument, default 18).
border – If truthy, a rectangle outline is drawn around the box.
Examples
box = TextBox((10, 10), 380, 200, text="Hello World!") box.font_size = 16
- __init__(position, width, height, **kwargs)[source]
Creates a text box with fixed width and height.
- Parameters:
position – Top-left position of the text box.
width – Maximum width in pixels before text is wrapped.
height – Maximum height in pixels.
border – Optional keyword argument. If truthy, draw a rectangle around the text box.
font_size – Optional keyword argument. Font size used for all lines.
- create_line(position, txt='')[source]
Create a single Text actor for one rendered line.
- Return type:
Text- Parameters:
position – Top-left position of the line.
txt – Text content of the line.
- Returns:
The created text actor.
- create_line_actors()[source]
Build visible text lines for the current text box content.
The text is split line by line and then wrapped after words so that no rendered line becomes wider than self.line_width. Each line is stored as a child Text actor.
Examples
box.text = "New text" box.create_line_actors()