paidiverpy.frontend.render#
WidgetRenderer class for rendering widgets based on configuration parameters.
Classes#
Class for rendering widgets based on configuration parameters. |
Module Contents#
- class paidiverpy.frontend.render.WidgetRenderer(steps: bool = False, step_parameters: paidiverpy.utils.base_model.BaseModel | None = None)[source]#
Class for rendering widgets based on configuration parameters.
- Parameters:
- create_widget(name: str, field: dict, html_h_tag: int = 2) panel.Column[source]#
Create a widget based on the field type and name.
- create_optional_widget(name: str, field: dict, options: list[str], default: str | float | bool | None = None, html_h_tag: int = 2) panel.Column[source]#
Create a widget for an optional field.
- Parameters:
- Returns:
A Panel Column containing the title and the input widget.
- Return type:
pn.Column
- render_custom_types(model_class: str, prefix: str | None = None, html_h_tag: int = 2) panel.Column[source]#
Render custom types based on the model class and field definition.
- Parameters:
- Returns:
A Panel Column containing the rendered widgets.
- Return type:
pn.Column
- render_list_input(field: dict, name: str, html_h_tag: int = 2) panel.Column[source]#
Render a list input widget based on the field definition.
- render_union_input(selected_type: str, field: dict, name: str, default: str | float | bool | None = None, provide: bool = True, html_h_tag: int = 2) panel.widgets.Widget[source]#
Render the input widget for a union type field.
- Parameters:
selected_type (str) – The selected type from the union.
field (dict) – The field definition containing type, description, default value, etc.
name (str) – The name of the field.
default (str | float | bool | None) – The default value for the field.
provide (bool) – Whether to provide the input widget or not.
html_h_tag (int) – The HTML heading tag level for the title.
- Returns:
The input widget for the selected type.
- Return type:
pn.widgets.Widget
- get_input_widget(type_: str, field: dict, name: str, default: str | float | bool | None = None, html_h_tag: int = 2, provide: bool = True) panel.widgets.Widget | None[source]#
Get the input widget based on the type and field definition.
- Parameters:
type (str) – The type of the field.
field (dict) – The field definition containing type, description, default value, etc.
name (str) – The name of the field.
default (str | float | bool | None) – The default value for the field.
html_h_tag (int) – The HTML heading tag level for the title.
provide (bool) – Whether to provide the input widget or not.
- Returns:
The input widget for the field, or None if not applicable.
- Return type:
pn.widgets.Widget | None
- render_method_with_mode_params(field_meta: dict, model_class: str, prefix: str | None = None, html_h_tag: int = 2, widgets: list[panel.Column] | None = None) list[panel.Column][source]#
Render the method with mode and parameters based on the field metadata.
- Parameters:
- Returns:
A list of Panel Columns containing the rendered widgets.
- Return type:
list[pn.Column]
- widget_from_literal(field_name: str, literal_type: Literal['option1', 'option2', 'option3']) panel.widgets.Select[source]#
Create a widget from a literal type.
- Parameters:
field_name (str) – The name of the field.
literal_type (Literal) – The literal type to create the widget from.
- Returns:
A Panel Select widget with options from the literal type.
- Return type:
pn.widgets.Select