WrapperComponent

Extends the base component interface to allow for the construction of interesting compound interfaces (using JHTML.Compound). Takes a dict of wrappers naming the successive levels of the interface along with a theme that provides style declarations for each level.

Used primarily to create Bootstrap-based interfaces.

wrappers: dict
theme: dict

 

__init__(self, items: Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType, Tuple[Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType], Mapping], NoneType, Iterable[Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType, Tuple[Union[str, Mapping, McUtils.Jupyter.Apps.types.HTMLableType, McUtils.Jupyter.Apps.types.WidgetableType, McUtils.Jupyter.Apps.types.IPyHTMLableType, McUtils.Jupyter.Apps.types.ImageableType], Mapping]]]], wrappers=None, theme=None, extend_base_theme=True, **attrs): 

LLM Docstring

A component that renders its items inside one or more themed wrapper elements (the basis for Bootstrap interfaces).

  • items: Any

    the wrapped items

  • wrappers: dict | None

    the named wrapper element classes

  • theme: dict | None

    the per-wrapper style theme

  • extend_base_theme: bool

    merge with the class’s base theme

  • attrs: Any

    extra attributes (merged into the outer wrapper’s theme)

 

handle_variants(self, theme): 

LLM Docstring

Expand a theme’s variant/base-cls shorthand into the concrete base-cls-variant CSS class.

  • theme: dict

    the theme

  • :returns: dict

    the expanded theme

 

manage_theme(self, theme, extend_base_theme=True): 

LLM Docstring

Resolve the effective theme, optionally merging it over the class’s base theme.

  • theme: Any

    the supplied theme (the class theme if None)

  • extend_base_theme: bool

    merge with the base theme

  • :returns: dict

    the resolved theme

 

@classmethod
merge_themes(cls, theme: 'None|dict', attrs: dict, merge_keys=('cls',)): 

Needs to handle cases where a theme is provided which includes things like cls declarations and then the attrs may also include cls declarations and the attrs declarations get appended to the theme

 

@classmethod
manage_items(cls, items, attrs): 

LLM Docstring

Normalize the items spec into a (items_list, attrs) pair, pulling out any attribute dict (from a dict body or a (items, opts) pair) and wrapping a scalar item in a list.

  • items: Any

    the items spec

  • attrs: dict

    the base attributes

  • :returns: tuple

    (items_list, attrs)

 

get_child(self, key): 

LLM Docstring

Get a wrapped item by index.

  • key: Any

    the item index

  • :returns: _

    the item

 

set_child(self, which, new): 

LLM Docstring

Set a wrapped item by index.

  • which: Any

    the item index

  • new: Any

    the new item

 

insert_child(self, where, child): 

LLM Docstring

Insert a wrapped item at a position (appending if where is None).

  • where: Any

    the index

  • child: Any

    the item

 

wrap_items(self, items): 

LLM Docstring

Render the items inside the wrapper element(s), applying the themed attributes.

  • items: Any

    the items to wrap

  • :returns: _

    the wrapper element

 

to_jhtml(self, parent=None): 

LLM Docstring

Render the component by wrapping its items.

  • parent: Any

    the parent component

  • :returns: _

    the JHTML element


Feedback

Examples

Templates

Documentation