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

Function actions

pywebio/input.py:480–578  ·  view source on GitHub ↗

r"""Actions selection It is displayed as a group of buttons on the page. After the user clicks the button of it, it will behave differently depending on the type of the button. :param list buttons: list of buttons. The available formats of the list items are: * dict::

(label: str = '', buttons: List[Union[Dict[str, Any], Tuple, List, str]] = None, name: str = None,
            help_text: str = None)

Source from the content-addressed store, hash-verified

478
479
480def actions(label: str = '', buttons: List[Union[Dict[str, Any], Tuple, List, str]] = None, name: str = None,
481 help_text: str = None):
482 r"""Actions selection
483
484 It is displayed as a group of buttons on the page. After the user clicks the button of it,
485 it will behave differently depending on the type of the button.
486
487 :param list buttons: list of buttons. The available formats of the list items are:
488
489 * dict::
490
491 {
492 "label":(str) button label,
493 "value":(object) button value,
494 "type":(str, optional) button type,
495 "disabled":(bool, optional) whether the button is disabled,
496 "color":(str, optional) button color
497 }
498
499 When ``type='reset'/'cancel'`` or ``disabled=True``, ``value`` can be omitted
500 * tuple or list: ``(label, value, [type], [disabled])``
501 * single value: label and value of button use the same value
502
503 The ``value`` of button can be any JSON serializable object.
504
505 ``type`` can be:
506
507 * ``'submit'`` : After clicking the button, the entire form is submitted immediately,
508 and the value of this input item in the final form is the ``value`` of the button that was clicked.
509 ``'submit'`` is the default value of ``type``
510 * ``'cancel'`` : Cancel form. After clicking the button, the entire form will be submitted immediately,
511 and the form value will return ``None``
512 * ``'reset'`` : Reset form. After clicking the button, the entire form will be reset,
513 and the input items will become the initial state.
514 Note: After clicking the ``type=reset`` button, the form will not be submitted,
515 and the ``actions()`` call will not return
516
517 The ``color`` of button can be one of: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`,
518 `dark`.
519
520 :param - label, name, help_text: Those arguments have the same meaning as for `input()`
521 :return: If the user clicks the ``type=submit`` button to submit the form,
522 return the value of the button clicked by the user.
523 If the user clicks the ``type=cancel`` button or submits the form by other means, ``None`` is returned.
524
525 When ``actions()`` is used as the last input item in `input_group()` and contains a button with ``type='submit'``,
526 the default submit button of the `input_group()` form will be replace with the current ``actions()``
527
528 **usage scenes of actions() **
529
530 .. _custom_form_ctrl_btn:
531
532 * Perform simple selection operations:
533
534 .. exportable-codeblock::
535 :name: actions-select
536 :summary: Use `actions()` to perform simple selection
537

Callers 15

put_actionsFunction · 0.90
targetFunction · 0.85
targetFunction · 0.85
targetFunction · 0.85
targetFunction · 0.85
async_targetFunction · 0.85
targetFunction · 0.85
targetFunction · 0.85
async_targetFunction · 0.85
targetFunction · 0.85
targetFunction · 0.85
targetFunction · 0.85

Calls 3

_parse_argsFunction · 0.85
_parse_action_buttonsFunction · 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…