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

Function set_progressbar

pywebio/output.py:1019–1045  ·  view source on GitHub ↗

Set the progress of progress bar :param str name: The name of the progress bar :param float value: The 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 percentage value of the current progress. See also

(name: str, value: float, label: str = None)

Source from the content-addressed store, hash-verified

1017
1018
1019def set_progressbar(name: str, value: float, label: str = None):
1020 """Set the progress of progress bar
1021
1022 :param str name: The name of the progress bar
1023 :param float value: The progress value of the progress bar. The value is between 0 and 1
1024 :param str label: The label of progress bar. The default is the percentage value of the current progress.
1025
1026 See also: `put_progressbar()`
1027 """
1028 from pywebio.session import run_js
1029
1030 check_dom_name_value(name)
1031
1032 progressbar_id = 'webio-progressbar-%s' % name
1033 percentage = value * 100
1034 label = '%.1f%%' % percentage if label is None else label
1035
1036 js_code = """
1037 let bar = $("#{progressbar_id}");
1038 bar[0].style.width = "{percentage}%";
1039 bar.attr("aria-valuenow", "{value}");
1040 bar.text({label!r});
1041 """.format(progressbar_id=progressbar_id, percentage=percentage, value=value, label=label)
1042 if value == 1:
1043 js_code += "if(bar.data('autoClose')=='1')bar.parent().remove();"
1044
1045 run_js(js_code)
1046
1047
1048put_processbar = put_progressbar

Callers

nothing calls this directly

Calls 2

check_dom_name_valueFunction · 0.85
run_jsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…