MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / checkbox

Function checkbox

pywebio/input.py:390–411  ·  view source on GitHub ↗

r"""A group of check box that allowing single values to be selected/deselected. :param list options: List of options. The format is the same as the ``options`` parameter of the `select()` function :param bool inline: Whether to display the options on one line. Default is ``False`` :para

(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str]] = None, *, inline: bool = None,
             validate: Callable[[Any], Optional[str]] = None,
             name: str = None, value: List = None, onchange: Callable[[Any], None] = None, help_text: str = None,
             **other_html_attrs)

Source from the content-addressed store, hash-verified

388
389
390def checkbox(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str]] = None, *, inline: bool = None,
391 validate: Callable[[Any], Optional[str]] = None,
392 name: str = None, value: List = None, onchange: Callable[[Any], None] = None, help_text: str = None,
393 **other_html_attrs):
394 r"""A group of check box that allowing single values to be selected/deselected.
395
396 :param list options: List of options. The format is the same as the ``options`` parameter of the `select()` function
397 :param bool inline: Whether to display the options on one line. Default is ``False``
398 :param list value: The value list of the initial selected items.
399 You can also set the initial selected option by setting the ``selected`` field in the ``options`` list item.
400 :param - label, validate, name, onchange, help_text, other_html_attrs: Those arguments have the same meaning as for `input()`
401 :return: A list of the values in the ``options`` selected by the user
402 """
403 assert options is not None, 'Required `options` parameter in checkbox()'
404
405 item_spec, valid_func, onchange_func = _parse_args(locals(), excludes=['value'])
406 item_spec['options'] = _parse_select_options(options)
407 if value is not None:
408 item_spec['options'] = _set_options_selected(item_spec['options'], value)
409 item_spec['type'] = CHECKBOX
410
411 return single_input(item_spec, valid_func, lambda d: d, onchange_func)
412
413
414def radio(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str]] = None, *, inline: bool = None,

Callers 4

put_checkboxFunction · 0.90
basic_inputFunction · 0.85
mainFunction · 0.85
formFunction · 0.85

Calls 4

_parse_argsFunction · 0.85
_parse_select_optionsFunction · 0.85
_set_options_selectedFunction · 0.85
single_inputFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…