editors
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| BooleanEditor promptantic.textual.editors A switch; a three-way select when ``null`` is allowed too. |
||
| ChoiceEditor promptantic.textual.editors A select of the allowed values; just the value when there's only one (``const``). |
||
| Editor promptantic.textual.editors Base of all editors: a node, its path in the value, and an error line. |
||
| ListEditor promptantic.textual.editors Items of one kind (add / remove), or the fixed positions of a tuple. |
||
| MapEditor promptantic.textual.editors Free keys with values of one kind (``dict[str, X]``). |
||
| MultiChoiceEditor promptantic.textual.editors Pick several of a fixed set (a unique list of choices). |
||
| NullEditor promptantic.textual.editors Nothing to enter: the value is ``null``. |
||
| ObjectEditor promptantic.textual.editors Named fields; nested objects fold (the outermost one doesn't). |
||
| TextEditor promptantic.textual.editors Typed input: text, numbers, or free JSON. |
||
| UnionEditor promptantic.textual.editors Pick the kind first, then fill that kind's editor. |
🛈 DocStrings¶
One Textual editor per kind of form node.
Every editor shows its field, checks it while the user types (the field's own
constraints, from :func:~promptantic.form.field_errors), and gives its current
value (:meth:Editor.get_value). The whole value is validated on submit.
Registry
¶
Registry = Callable[[Path, Editor], None]
Called by every editor on mount, so the form can show issues at their path.
BooleanEditor
¶
Bases: Editor
A switch; a three-way select when null is allowed too.
Source code in src/promptantic/textual/editors.py
ChoiceEditor
¶
Bases: Editor
A select of the allowed values; just the value when there's only one (const).
Source code in src/promptantic/textual/editors.py
Editor
¶
Bases: Widget
Base of all editors: a node, its path in the value, and an error line.
Source code in src/promptantic/textual/editors.py
check
¶
Show what's wrong with this field alone (on every change).
Source code in src/promptantic/textual/editors.py
get_value
¶
The value entered so far (:data:UNSET: nothing).
Raises:
| Type | Description |
|---|---|
FieldError
|
Input that can't become a value (e.g. text in a number field). |
ListEditor
¶
Bases: Editor
Items of one kind (add / remove), or the fixed positions of a tuple.
Source code in src/promptantic/textual/editors.py
MapEditor
¶
Bases: Editor
Free keys with values of one kind (dict[str, X]).
Source code in src/promptantic/textual/editors.py
MultiChoiceEditor
¶
Bases: Editor
Pick several of a fixed set (a unique list of choices).
Source code in src/promptantic/textual/editors.py
NullEditor
¶
Bases: Editor
Nothing to enter: the value is null.
Source code in src/promptantic/textual/editors.py
ObjectEditor
¶
Bases: Editor
Named fields; nested objects fold (the outermost one doesn't).
Fields with only one possible value (const, e.g. a union's discriminator) aren't
shown; their value is still part of the result. An object that may be null
starts with a switch: off means null, on shows its fields.
Source code in src/promptantic/textual/editors.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
TextEditor
¶
Bases: Editor
Typed input: text, numbers, or free JSON.
Source code in src/promptantic/textual/editors.py
UnionEditor
¶
Bases: Editor
Pick the kind first, then fill that kind's editor.
Source code in src/promptantic/textual/editors.py
make_editor
¶
The editor for node (initial: its starting value, or :data:UNSET).