# progress_bar_str¶

menpo.visualize.progress_bar_str(percentage, bar_length=20, bar_marker='=', show_bar=True)[source]

Returns an str of the specified progress percentage. The percentage is represented either in the form of a progress bar or in the form of a percentage number. It can be combined with the print_dynamic() function.

Parameters
• percentage (float) – The progress percentage to be printed. It must be in the range [0, 1].

• bar_length (int, optional) – Defines the length of the bar in characters.

• bar_marker (str, optional) – Defines the marker character that will be used to fill the bar.

• show_bar (bool, optional) –

If True, the str includes the bar followed by the percentage, e.g. '[=====     ] 50%'

If False, the str includes only the percentage, e.g. '50%'

Returns

progress_str (str) – The progress percentage string that can be printed.

Raises
• ValueErrorpercentage is not in the range [0, 1]

• ValueErrorbar_length must be an integer >= 1

• ValueErrorbar_marker must be a string of length 1

Examples

This for loop:

n_iters = 2000
for k in range(n_iters):
print_dynamic(progress_bar_str(float(k) / (n_iters-1)))


prints a progress bar of the form:

[=============       ] 68%