Skip to content

Commit 457b605

Browse files
committed
typo: process bar -> progress bar
1 parent 275cbce commit 457b605

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

pywebio/output.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
| +---------------------------+------------------------------------------------------------+
4343
| | `put_link` | Output link |
4444
| +---------------------------+------------------------------------------------------------+
45-
| | `put_processbar` | Output a process bar |
45+
| | `put_progressbar` | Output a progress bar |
4646
| +---------------------------+------------------------------------------------------------+
4747
| | `put_loading`:sup:`†` | Output loading prompt |
4848
| +---------------------------+------------------------------------------------------------+
@@ -173,8 +173,8 @@
173173
174174
.. autofunction:: put_html
175175
.. autofunction:: put_link
176-
.. autofunction:: put_processbar
177-
.. autofunction:: set_processbar
176+
.. autofunction:: put_progressbar
177+
.. autofunction:: set_progressbar
178178
.. autofunction:: put_loading
179179
.. autofunction:: put_code
180180
.. autofunction:: put_table
@@ -226,12 +226,12 @@
226226

227227
logger = logging.getLogger(__name__)
228228

229-
__all__ = ['Position', 'remove', 'scroll_to', 'put_tabs', 'put_scope',
229+
__all__ = ['Position', 'OutputPosition', 'remove', 'scroll_to', 'put_tabs', 'put_scope',
230230
'put_text', 'put_html', 'put_code', 'put_markdown', 'use_scope', 'set_scope', 'clear', 'remove',
231231
'put_table', 'put_buttons', 'put_image', 'put_file', 'PopupSize', 'popup', 'put_button',
232232
'close_popup', 'put_widget', 'put_collapse', 'put_link', 'put_scrollable', 'style', 'put_column',
233-
'put_row', 'put_grid', 'span', 'put_processbar', 'set_processbar', 'put_loading',
234-
'output', 'toast', 'get_scope', 'put_info', 'put_error', 'put_warning', 'put_success']
233+
'put_row', 'put_grid', 'span', 'put_progressbar', 'set_progressbar', 'put_processbar', 'set_processbar',
234+
'put_loading', 'output', 'toast', 'get_scope', 'put_info', 'put_error', 'put_warning', 'put_success']
235235

236236

237237
# popup size
@@ -958,74 +958,78 @@ def put_link(name: str, url: str = None, app: str = None, new_window: bool = Fal
958958
return put_html(tag, scope=scope, position=position)
959959

960960

961-
def put_processbar(name: str, init: float = 0, label: str = None, auto_close: bool = False, scope: str = None,
962-
position: int = OutputPosition.BOTTOM) -> Output:
963-
"""Output a process bar
961+
def put_progressbar(name: str, init: float = 0, label: str = None, auto_close: bool = False, scope: str = None,
962+
position: int = OutputPosition.BOTTOM) -> Output:
963+
"""Output a progress bar
964964
965965
:param str name: The name of the progress bar, which is the unique identifier of the progress bar
966966
:param float init: The initial progress value of the progress bar. The value is between 0 and 1
967-
:param str label: The label of process bar. The default is the percentage value of the current progress.
967+
:param str label: The label of progress bar. The default is the percentage value of the current progress.
968968
:param bool auto_close: Whether to remove the progress bar after the progress is completed
969969
:param int scope, position: Those arguments have the same meaning as for `put_text()`
970970
971971
Example:
972972
973973
.. exportable-codeblock::
974-
:name: put_processbar
975-
:summary: `put_processbar()` usage
974+
:name: put_progressbar
975+
:summary: `put_progressbar()` usage
976976
977977
import time
978978
979-
put_processbar('bar');
979+
put_progressbar('bar');
980980
for i in range(1, 11):
981-
set_processbar('bar', i / 10)
981+
set_progressbar('bar', i / 10)
982982
time.sleep(0.1)
983983
984-
.. seealso:: use `set_processbar()` to set the progress of progress bar
984+
.. seealso:: use `set_progressbar()` to set the progress of progress bar
985985
"""
986986
check_dom_name_value(name)
987-
processbar_id = 'webio-processbar-%s' % name
987+
progressbar_id = 'webio-progressbar-%s' % name
988988
percentage = init * 100
989989
label = '%.1f%%' % percentage if label is None else label
990990
tpl = """<div class="progress" style="margin-top: 4px;">
991991
<div id="{{elem_id}}" class="progress-bar bg-info progress-bar-striped progress-bar-animated" role="progressbar"
992992
style="width: {{percentage}}%;" aria-valuenow="{{init}}" aria-valuemin="0" aria-valuemax="1" data-auto-close="{{auto_close}}">{{label}}
993993
</div>
994994
</div>"""
995-
return put_widget(tpl, data=dict(elem_id=processbar_id, init=init, label=label,
995+
return put_widget(tpl, data=dict(elem_id=progressbar_id, init=init, label=label,
996996
percentage=percentage, auto_close=int(bool(auto_close))), scope=scope,
997997
position=position)
998998

999999

1000-
def set_processbar(name: str, value: float, label: str = None):
1000+
def set_progressbar(name: str, value: float, label: str = None):
10011001
"""Set the progress of progress bar
10021002
10031003
:param str name: The name of the progress bar
10041004
:param float value: The progress value of the progress bar. The value is between 0 and 1
1005-
:param str label: The label of process bar. The default is the percentage value of the current progress.
1005+
:param str label: The label of progress bar. The default is the percentage value of the current progress.
10061006
1007-
See also: `put_processbar()`
1007+
See also: `put_progressbar()`
10081008
"""
10091009
from pywebio.session import run_js
10101010

10111011
check_dom_name_value(name)
10121012

1013-
processbar_id = 'webio-processbar-%s' % name
1013+
progressbar_id = 'webio-progressbar-%s' % name
10141014
percentage = value * 100
10151015
label = '%.1f%%' % percentage if label is None else label
10161016

10171017
js_code = """
1018-
let bar = $("#{processbar_id}");
1018+
let bar = $("#{progressbar_id}");
10191019
bar[0].style.width = "{percentage}%";
10201020
bar.attr("aria-valuenow", "{value}");
10211021
bar.text({label!r});
1022-
""".format(processbar_id=processbar_id, percentage=percentage, value=value, label=label)
1022+
""".format(progressbar_id=progressbar_id, percentage=percentage, value=value, label=label)
10231023
if value == 1:
10241024
js_code += "if(bar.data('autoClose')=='1')bar.parent().remove();"
10251025

10261026
run_js(js_code)
10271027

10281028

1029+
put_processbar = put_progressbar
1030+
set_processbar = set_progressbar
1031+
1032+
10291033
def put_loading(shape: str = 'border', color: str = 'dark', scope: str = None,
10301034
position: int = OutputPosition.BOTTOM) -> Output:
10311035
"""Output loading prompt

0 commit comments

Comments
 (0)