Skip to content
프로젝트

소개

군더더기 없이 가장 간단한 Python 진행 표시줄

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
업데이트 지연
in 7 days
-1
in 15 days
-2
in 1 month
업데이트 지연

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

lowbar

The simplest no-nonsense progress bar for python.
Jump to the API reference

Preview GIF

lowbar is a blazing fast module with zero dependencies for displaying a progress bar in the terminal. It has a low number of features and a simple codebase, hence the name lowbar.

lowbar has:

  • Automatic resizing
  • Manual progress management
  • Automatic progress management (As an iterable)
  • Text logging
  • Bar styling
  • Low overhead
  • Small size ( < 150 lines)

lowbar doesn't have:

  • Nested bars
  • Fancy animations
  • ETA calculations

Requirements

  • Python 3.7 or above. lowbar may support earlier versions, but this has not been tested.
  • A console that supports line feed \n and carriage return \r.

Installation

Install the latest stable release:

pip install lowbar

Or the development version:

pip install git+https://github.com/AnnikaV9/lowbar

Usage

Once you have lowbar installed, you can import it like any other module:

from lowbar import lowbar

And initialize the bar:

bar = lowbar()

To make the bar visible and set at 0%:

bar.new()

After completing some tasks, we can increase the bar's completion percentage:

bar.add(20)

If we have a known number of tasks, lowbar can automatically calculate the percentage for us:

bar.next(n_tasks)

[!NOTE] If you set the number of tasks when initializing lowbar with lowbar(n_tasks), you don't need to pass n_tasks to next().

We can also set the completion percentage instead of adding to it:

bar.update(50)

Using print() or other similar functions will push the bar up, which doesn't look nice. To log messages without affecting the bar:

bar.log("Hello World!")

And finally, to clear the bar completely:

bar.clear()

Here's an example usage of the bar:

bar = lowbar(10)
bar.new()
for i in range(10):
    time.sleep(0.5)  # task
    bar.log(f"Task {i+1} completed")
    bar.next()
bar.clear()

print("Tasks complete!")

You don't even need a loop:

bar.new()
time.sleep(0.5)  # task
bar.add(10)
time.sleep(0.5)  # task
bar.add(10)
time.sleep(0.5)  # task
bar.update(100)
bar.clear()

print("Tasks complete!")

The bar can also be used with a context manager. It will automatically run new() at the start and clear() when exiting:

with lowbar(2) as bar:
    time.sleep(0.5)  # task
    bar.next()
    time.sleep(0.5)  # task
    bar.next()

print("Tasks complete!")

To make things simpler, you can wrap lowbar around range() and turn it into an iterable. It will automatically calculate how much to increase the percentage by every loop:

for i in lowbar(range(100)):
    time.sleep(0.5)  # task

Pass an integer and lowbar will convert it into a range object for you:

for i in lowbar(100):
    time.sleep(0.5)  # task

[!NOTE] You can't use log() when using lowbar as an iterable.

You can also change the load fill and blank fill chars:

bar = lowbar(load_fill="O", blank_fill=".")

Or add a description text to the left side of the bar:

bar = lowbar(desc="Downloading...")

[!NOTE] If the console is too small to accommodate both the bar and the description text, the text will be hidden.


See the API reference

Contributing

All contributions are welcome!

If you wish to report a bug or suggest a feature, open an issue.

You can also make a pull request directly if you already have the fix for a bug.

See CONTRIBUTING.md for guidelines to follow.

Contributors are listed in CONTRIBUTORS.md.

License

This project is licensed under the MIT License.

관련 프로젝트 살펴보기

불러오는 중…