Div¶
pywry.toolbar.Div
¶
Bases: ToolbarItem
A container div for custom HTML content within a toolbar.
Supports nested toolbar items and custom scripts for advanced layouts. Parent context (component IDs) is passed to children via data-parent-id attribute.
Emits: No automatic events (unless content has interactive elements)
| ATTRIBUTE | DESCRIPTION |
|---|---|
content |
HTML content to render inside the div.
TYPE:
|
script |
JS file path or inline string to inject (executed after toolbar script).
TYPE:
|
class_name |
Custom CSS class for the div container.
TYPE:
|
children |
Nested toolbar items (Button, Select, other Divs, etc.).
TYPE:
|
Examples:
>>> Div(
... content="<h3>Controls</h3>",
... class_name="my-controls",
... children=[
... Button(label="Action", event="app:action"),
... Div(content="<span>Nested</span>", class_name="nested-div"),
... ],
... )
Functions¶
build_html
¶
Build div HTML with content and nested children.
| PARAMETER | DESCRIPTION |
|---|---|
parent_id
|
Parent component ID for context chain inheritance.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
HTML string for the div container. |
collect_scripts
¶
Collect scripts from this div and all nested children (depth-first).
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of script content strings (file contents or inline scripts). |
auto_generate_component_id
¶
auto_generate_component_id() -> ToolbarItem
Auto-generate component_id based on type if not provided.
validate_event_name
classmethod
¶
Validate event follows namespace:event-name pattern.