╔══════════════════════════════════════════════════════════════╗ ║ textbox API Contents ║ ╚══════════════════════════════════════════════════════════════╝ 📦 textbox ├─ 📥 Import ├─ 📖 Overview ├─ 🧱 Creating a textbox ├─ 📊 Basic properties ├─ 🎨 Colors ├─ 📐 Layout ├─ ✨ Reveal and style ├─ ↔️ Slide-in support ├─ ⚙️ Methods ├─ ▶️ Example ├─ 🔤 Reveal example └─ 📝 Notes
📦 API Reference: textbox
The textbox class provides a simple UI text box that can draw framed text, auto-size itself, reveal text over time, and slide in from screen edges.
📥 Import
from retroPy import textbox
📖 Overview
textbox is a lightweight built-in UI helper for dialogue, prompts, and framed text overlays.
It supports:
- framed text drawing
- auto-sizing
- timed reveal effects
- simple slide-in motion
🧱 Creating a textbox
tb = textbox((20, 20), 120, 40)
Constructor arguments:
(x, y)tuplewidthheight
The position is stored as floats internally, while width and height are integers.
📊 Basic properties
Content and visibility
textbox.texttextbox.visibletextbox.duration
🎨 Colors
textbox.border_colortextbox.bg_colortextbox.text_color
📐 Layout
textbox.paddingtextbox.aligntextbox.auto_size
align is a string in the current implementation, with typical values such as:
"left""center""right"
✨ Reveal and style
textbox.reveal_modetextbox.border_style
Reveal modes in the current file:
0-> reveal by letter1-> reveal by word
Border styles in the current file:
0-> sharp border1-> rounded-corner style border
↔️ Slide-in support
textbox.slide_intextbox.slidingtextbox.slide_speedtextbox.target_xtextbox.target_y
The current slide-in mode values are:
1-> from right2-> from left3-> from bottom4-> from top
⚙️ Methods
textbox.draw()
Draws the textbox if it is visible.
tb.draw()
If auto_size is enabled, the box recalculates its width and height from the text before drawing.
textbox.update()
Updates duration countdown and reveal progression.
tb.update()
Call this once per frame if you are using timed visibility or reveal effects.
textbox.start_reveal(text, delay)
Begins a reveal effect.
tb.start_reveal("Welcome to retroPy", 2)
textis the full source textdelayis the frame delay between reveal steps
Whether the reveal advances by letters or words depends on textbox.reveal_mode.
Example
from retroPy import *
tb = textbox((20, 20), 120, 40)
tb.visible = True
tb.text = "Hello world"
tb.border_color = 15
tb.bg_color = 1
tb.text_color = 15
tb.align = "center"
draw.clear(0)
tb.draw()
disp.show()
Reveal example
from retroPy import *
tb = textbox((10, 10), 140, 40)
tb.reveal_mode = 0
tb.start_reveal("retroPy docs", 2)
def Update():
tb.update()
def Draw():
draw.clear(0)
tb.draw()
Notes
- The class uses the current built-in text renderer and draws each line character by character.
- The current implementation includes a
cancel_buttonproperty, but the cancel-button logic is commented out inupdate(). - Slide-in behavior is handled during
draw(), not in a separate animation system.