Output a progress bar :param str name: The name of the progress bar, which is the unique identifier of the progress bar :param float init: The initial progress value of the progress bar. The value is between 0 and 1 :param str label: The label of progress bar. The default is the percent
(name: str, init: float = 0, label: str = None, auto_close: bool = False, scope: str = None,
position: int = OutputPosition.BOTTOM)
| 978 | |
| 979 | |
| 980 | def put_progressbar(name: str, init: float = 0, label: str = None, auto_close: bool = False, scope: str = None, |
| 981 | position: int = OutputPosition.BOTTOM) -> Output: |
| 982 | """Output a progress bar |
| 983 | |
| 984 | :param str name: The name of the progress bar, which is the unique identifier of the progress bar |
| 985 | :param float init: The initial progress value of the progress bar. The value is between 0 and 1 |
| 986 | :param str label: The label of progress bar. The default is the percentage value of the current progress. |
| 987 | :param bool auto_close: Whether to remove the progress bar after the progress is completed |
| 988 | :param int scope, position: Those arguments have the same meaning as for `put_text()` |
| 989 | |
| 990 | Example: |
| 991 | |
| 992 | .. exportable-codeblock:: |
| 993 | :name: put_progressbar |
| 994 | :summary: `put_progressbar()` usage |
| 995 | |
| 996 | import time |
| 997 | |
| 998 | put_progressbar('bar'); |
| 999 | for i in range(1, 11): |
| 1000 | set_progressbar('bar', i / 10) |
| 1001 | time.sleep(0.1) |
| 1002 | |
| 1003 | .. seealso:: use `set_progressbar()` to set the progress of progress bar |
| 1004 | """ |
| 1005 | check_dom_name_value(name) |
| 1006 | progressbar_id = 'webio-progressbar-%s' % name |
| 1007 | percentage = init * 100 |
| 1008 | label = '%.1f%%' % percentage if label is None else label |
| 1009 | tpl = """<div class="progress" style="margin-top: 4px;"> |
| 1010 | <div id="{{elem_id}}" class="progress-bar bg-info progress-bar-striped progress-bar-animated" role="progressbar" |
| 1011 | style="width: {{percentage}}%;" aria-valuenow="{{init}}" aria-valuemin="0" aria-valuemax="1" data-auto-close="{{auto_close}}">{{label}} |
| 1012 | </div> |
| 1013 | </div>""" |
| 1014 | return put_widget(tpl, data=dict(elem_id=progressbar_id, init=init, label=label, |
| 1015 | percentage=percentage, auto_close=int(bool(auto_close))), scope=scope, |
| 1016 | position=position) |
| 1017 | |
| 1018 | |
| 1019 | def set_progressbar(name: str, value: float, label: str = None): |
nothing calls this directly
no test coverage detected
searching dependent graphs…