Toolbar¶
pywry.toolbar.Toolbar
¶
Bases: BaseModel
A toolbar container with positioned items.
| ATTRIBUTE | DESCRIPTION |
|---|---|
component_id |
Unique identifier for this toolbar (auto-generated if not provided).
TYPE:
|
position |
Where to place the toolbar: "top", "bottom", "left", "right", or "inside".
TYPE:
|
items |
List of toolbar items (Button, Select, TextInput, Div, etc.).
TYPE:
|
style |
Optional inline CSS for the toolbar container.
TYPE:
|
script |
JS file path or inline string to inject into the toolbar.
TYPE:
|
class_name |
Custom CSS class added to the toolbar container.
TYPE:
|
collapsible |
Enable collapse/expand behavior with toggle button.
TYPE:
|
resizable |
Enable drag-to-resize on toolbar edge (direction based on position).
TYPE:
|
Examples:
>>> Toolbar(
... position="top",
... class_name="my-toolbar",
... collapsible=True,
... resizable=True,
... items=[
... Button(label="Refresh", event="app:refresh"),
... Select(label="View:", event="view:change", options=[...]),
... Div(content="<span>Custom</span>", class_name="custom-section"),
... ],
... )
Functions¶
normalize_items
classmethod
¶
normalize_items(v: Any) -> list[ToolbarItem]
Accept list of dicts or ToolbarItem objects.
collect_scripts
¶
Collect scripts from toolbar and all nested Div children (depth-first).
Toolbar script runs first, then Div scripts in item order.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of script content strings. |
get_secret_inputs
¶
get_secret_inputs() -> list[SecretInput]
Get all SecretInput items in this toolbar (including nested in Divs).
| RETURNS | DESCRIPTION |
|---|---|
list[SecretInput]
|
All SecretInput components found. |
register_secrets
¶
Register all SecretInput values in the secret registry.
Called automatically when rendering. Ensures secrets are available for reveal/copy handlers.
get_secret_events
¶
Get all secret-related events that need handlers.
| RETURNS | DESCRIPTION |
|---|---|
list[tuple[str, str, str]]
|
List of (component_id, reveal_event, copy_event) tuples. |