Output a group of buttons and bind click event :param list buttons: Button list. The available formats of list items are: * dict:: { "label":(str)button label, "value":(str)button value, "color":(str, optional)button col
(buttons: List[Union[Dict[str, Any], Tuple[str, Any], List, str]],
onclick: Union[Callable[[Any], None], SequenceType[Callable[[], None]]],
small: bool = None, link_style: bool = False, outline: bool = False, group: bool = False,
scope: str = None,
position: int = OutputPosition.BOTTOM, **callback_options)
| 737 | |
| 738 | |
| 739 | def put_buttons(buttons: List[Union[Dict[str, Any], Tuple[str, Any], List, str]], |
| 740 | onclick: Union[Callable[[Any], None], SequenceType[Callable[[], None]]], |
| 741 | small: bool = None, link_style: bool = False, outline: bool = False, group: bool = False, |
| 742 | scope: str = None, |
| 743 | position: int = OutputPosition.BOTTOM, **callback_options) -> Output: |
| 744 | """ |
| 745 | Output a group of buttons and bind click event |
| 746 | |
| 747 | :param list buttons: Button list. The available formats of list items are: |
| 748 | |
| 749 | * dict:: |
| 750 | |
| 751 | { |
| 752 | "label":(str)button label, |
| 753 | "value":(str)button value, |
| 754 | "color":(str, optional)button color, |
| 755 | "disabled":(bool, optional) whether the button is disabled |
| 756 | } |
| 757 | |
| 758 | * tuple or list: ``(label, value)`` |
| 759 | * single value: label and value of option use the same value |
| 760 | |
| 761 | The ``value`` of button can be any type. |
| 762 | The ``color`` of button can be one of: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`. |
| 763 | |
| 764 | Example: |
| 765 | |
| 766 | .. exportable-codeblock:: |
| 767 | :name: put_buttons-btn_class |
| 768 | :summary: `put_buttons()` |
| 769 | |
| 770 | put_buttons([dict(label='success', value='s', color='success')], onclick=...) # ..doc-only |
| 771 | put_buttons([ # ..demo-only |
| 772 | dict(label=i, value=i, color=i) # ..demo-only |
| 773 | for i in ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'] # ..demo-only |
| 774 | ], onclick=put_text) # ..demo-only |
| 775 | |
| 776 | :type onclick: callable / list |
| 777 | :param onclick: Callback which will be called when button is clicked. ``onclick`` can be a callable object or a list of it. |
| 778 | |
| 779 | If ``onclick`` is callable object, its signature is ``onclick(btn_value)``. ``btn_value`` is ``value`` of the button that is clicked. |
| 780 | |
| 781 | If ``onclick`` is a list, the item receives no parameter. In this case, each item in the list corresponds to the buttons one-to-one. |
| 782 | |
| 783 | Tip: You can use ``functools.partial`` to save more context information in ``onclick``. |
| 784 | |
| 785 | Note: When in :ref:`Coroutine-based session <coroutine_based_session>`, the callback can be a coroutine function. |
| 786 | :param bool small: Whether to use small size button. Default is False. |
| 787 | :param bool link_style: Whether to use link style button. Default is False |
| 788 | :param bool outline: Whether to use outline style button. Default is False |
| 789 | :param bool group: Whether to group the buttons together. Default is False |
| 790 | :param int scope, position: Those arguments have the same meaning as for `put_text()` |
| 791 | :param callback_options: Other options of the ``onclick`` callback. There are different options according to the session implementation |
| 792 | |
| 793 | When in Coroutine-based Session: |
| 794 | * mutex_mode: Default is ``False``. If set to ``True``, new click event will be ignored when the current callback is running. |
| 795 | This option is available only when ``onclick`` is a coroutine function. |
| 796 |
no test coverage detected
searching dependent graphs…