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

Function put_progressbar

pywebio/output.py:980–1016  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

978
979
980def 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
1019def set_progressbar(name: str, value: float, label: str = None):

Callers

nothing calls this directly

Calls 2

check_dom_name_valueFunction · 0.85
put_widgetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…