API Reference
TextualApp
- class genro_textual.TextualApp(remote_port=None)[source]
The puppeteer: configures and drives a LiveApp.
Subclass and override recipe(page) to define your UI. Everything goes in the recipe: widgets, CSS, bindings.
- builder_class
alias of
TextualBuilder
- compiler_class
alias of
TextualCompiler
- property page: BuilderBag
The page Bag (UI structure). Domain name for source.
- property data: Bag
The data Bag. Setting values triggers reactive updates.
- recipe(page)[source]
Override to build your UI. page is a BuilderBag with TextualBuilder.
- Parameters:
page (
BuilderBag)- Return type:
TextualBuilder
- class genro_textual.textual_builder.TextualBuilder(bag, schema_path=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: compile() + render to Widget tree.
- Parameters:
builder (
Any)
- __init__(builder)[source]
Initialize compiler with builder reference.
- Parameters:
builder (
Any) – The BagBuilderBase instance that built the bag.
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 the recipe 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.