Takes a list of options and additional properties, checks if each option is an instance of Option, and returns a Select component with the given options and properties. No children allowed. Args: options (List[Option | str | int | float | bool]): A list of values
(
cls, options: List[Union[Option, str, int, float, bool]], **props
)
| 331 | |
| 332 | @classmethod |
| 333 | def create( |
| 334 | cls, options: List[Union[Option, str, int, float, bool]], **props |
| 335 | ) -> Component: |
| 336 | """Takes a list of options and additional properties, checks if each option is an |
| 337 | instance of Option, and returns a Select component with the given options and |
| 338 | properties. No children allowed. |
| 339 | |
| 340 | Args: |
| 341 | options (List[Option | str | int | float | bool]): A list of values. |
| 342 | **props: Additional properties to be passed to the Select component. |
| 343 | |
| 344 | Returns: |
| 345 | The `create` method is returning an instance of the `Select` class. |
| 346 | """ |
| 347 | converted_options: List[Option] = [] |
| 348 | if not isinstance(options, Var): |
| 349 | for option in options: |
| 350 | if not isinstance(option, Option): |
| 351 | converted_options.append(Option(label=str(option), value=option)) |
| 352 | else: |
| 353 | converted_options.append(option) |
| 354 | props["options"] = [o.dict() for o in converted_options] |
| 355 | else: |
| 356 | props["options"] = options |
| 357 | return super().create(*[], **props) |