API Reference
TextualApp
- class genro_textual.TextualApp(*args, **kw)[source]
The puppeteer: configures and drives a LiveApp.
Subclass and override main(page) to define your UI, and store(data) to populate initial data.
- property page: BuilderBag
The page Bag (UI structure). Domain name for source.
- property source: BuilderBag
Alias for page — the source Bag.
- property data: Bag
The data Bag. Setting values triggers reactive updates.
- property compiled: BuilderBag
The built Bag (components expanded, pointers formal).
- as_textual_app()[source]
Return the native Textual App for use with textual devtools.
Creates the LiveApp without starting it. The full lifecycle (store, main, build, subscribe, render) happens in on_mount().
This enables compatibility with
textual run --devandtextual serve:# In your example file: app = Application().as_textual_app() # Then run with: textual run --dev examples/my_app.py
- Return type:
TextualBuilder
- class genro_textual.textual_builder.TextualBuilder(bag=None, schema_path=None, *, manager=None, data=None)[source]
Builder for Textual TUI elements.
Includes FoundationMixin (app_shell) and TextualWidgetsMixin (all widgets). Subclass TextualBuilder freely — mixin schemas are inherited via MRO.
To add custom components, define them in a mixin:
from genro_builders.builder import component class MyMixin: @component(sub_tags="") def login_form(self, comp, **kwargs): comp.input(placeholder="Username") comp.button("Login") class MyBuilder(MyMixin, TextualBuilder): pass
To exclude FoundationMixin, compose your own builder:
class MinimalBuilder(TextualWidgetsMixin, BagBuilderBase): pass
TextualCompiler
- class genro_textual.textual_compiler.TextualCompiler(builder)[source]
Compiler for Textual: built Bag -> Widget tree.
- Parameters:
builder (
Any)
LiveApp
- class genro_textual.textual_app.LiveApp(owner)[source]
The puppet: a bare textual.app.App driven by TextualApp.
Has no CSS or BINDINGS of its own — those come from main() and are applied by the compiler at render time. Delegates events to the owner (TextualApp).
- Parameters:
owner (
TextualApp)
- BINDINGS = [('q', 'quit', 'Quit')]
The default key bindings.
- __init__(owner)[source]
Create an instance of an app.
- Parameters:
driver_class – Driver class or None to auto-detect. This will be used by some Textual tools.
css_path – Path to CSS or None to use the CSS_PATH class variable. To load multiple CSS files, pass a list of strings or paths which will be loaded in order.
watch_css – Reload CSS if the files changed. This is set automatically if you are using textual run with the dev switch.
ansi_color – Allow ANSI colors if True, or convert ANSI colors to RGB if False.
owner (
TextualApp)
- Raises:
CssPathError – When the supplied CSS path(s) are an unexpected type.
- compose()[source]
Yield child widgets for a container.
This method should be implemented in a subclass.