|
52 | 52 | | +---------------------------+------------------------------------------------------------+ |
53 | 53 | | | `put_table`:sup:`*` | Output table | |
54 | 54 | | +---------------------------+------------------------------------------------------------+ |
55 | | -| | `put_buttons` | Output a group of buttons and bind click event | |
| 55 | +| | | `put_button` | Output button and bind click event | |
| 56 | +| | | `put_buttons` | | |
56 | 57 | | +---------------------------+------------------------------------------------------------+ |
57 | 58 | | | `put_image` | Output image | |
58 | 59 | | +---------------------------+------------------------------------------------------------+ |
|
124 | 125 | .. autofunction:: put_table |
125 | 126 | .. autofunction:: span |
126 | 127 | .. autofunction:: put_buttons |
| 128 | +.. autofunction:: put_button |
127 | 129 | .. autofunction:: put_image |
128 | 130 | .. autofunction:: put_file |
129 | 131 | .. autofunction:: put_tabs |
|
173 | 175 |
|
174 | 176 | __all__ = ['Position', 'remove', 'scroll_to', 'put_tabs', |
175 | 177 | 'put_text', 'put_html', 'put_code', 'put_markdown', 'use_scope', 'set_scope', 'clear', 'remove', |
176 | | - 'put_table', 'put_buttons', 'put_image', 'put_file', 'PopupSize', 'popup', |
| 178 | + 'put_table', 'put_buttons', 'put_image', 'put_file', 'PopupSize', 'popup', 'put_button', |
177 | 179 | 'close_popup', 'put_widget', 'put_collapse', 'put_link', 'put_scrollable', 'style', 'put_column', |
178 | 180 | 'put_row', 'put_grid', 'span', 'put_processbar', 'set_processbar', 'put_loading', |
179 | 181 | 'output', 'toast', 'get_scope', 'put_info', 'put_error', 'put_warning', 'put_success'] |
@@ -722,6 +724,28 @@ def click_callback(btn_val): |
722 | 724 | return Output(spec) |
723 | 725 |
|
724 | 726 |
|
| 727 | +def put_button(label, onclick, color=None, small=None, link_style=False, outline=False, scope=Scope.Current, |
| 728 | + position=OutputPosition.BOTTOM) -> Output: |
| 729 | + """Output a single button and bind click event to it. |
| 730 | +
|
| 731 | + :param str label: Button label |
| 732 | + :param callable onclick: Callback which will be called when button is clicked. |
| 733 | + :param str color: The color of the button, |
| 734 | + can be one of: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`. |
| 735 | + :param - small, link_style, outline, scope, position: Those arguments have the same meaning as for `put_buttons()` |
| 736 | +
|
| 737 | + Example: |
| 738 | +
|
| 739 | + .. exportable-codeblock:: |
| 740 | + :name: put_button |
| 741 | + :summary: `put_button()` usage |
| 742 | +
|
| 743 | + put_button("click me", onclick=lambda: toast("Clicked"), color='success', outline=True) |
| 744 | + """ |
| 745 | + return put_buttons([{'label': label, 'value': '', 'color': color or 'primary'}], onclick=[onclick], |
| 746 | + small=small, link_style=link_style, outline=outline, scope=scope, position=position) |
| 747 | + |
| 748 | + |
725 | 749 | def put_image(src, format=None, title='', width=None, height=None, |
726 | 750 | scope=Scope.Current, position=OutputPosition.BOTTOM) -> Output: |
727 | 751 | """Output image |
|
0 commit comments