DEV Community

Cover image for Alive Progress Bars ๐Ÿš€
Lawani Elyon John
Lawani Elyon John

Posted on

Alive Progress Bars ๐Ÿš€

Add Life to Your Terminal with Alive Progress Bar

If youโ€™re tired of plain terminal output, hereโ€™s something fun! This demo uses the alive_progress library to add an interactive progress bar that visually updates as tasks progress. Itโ€™s perfect for those times when you want to bring some life to your terminal! ๐ŸŽจ

๐Ÿ“ What is Alive Progress Bar?

alive_progress creates an animated progress bar that adapts to task speed, making it great for visualizing longer tasks and improving UX in CLI apps. Plus, itโ€™s open-source and easy to implement!

๐Ÿ› ๏ธ Setting Up

  1. Install alive_progress by running:
   pip install alive-progress
Enter fullscreen mode Exit fullscreen mode
  1. Run the Code

Hereโ€™s a simple example:

   from alive_progress import alive_bar
   import time

   for x in 1000, 1500, 700, 0:
       with alive_bar(x) as bar:
           for i in range(1000):
               time.sleep(.005)
               bar()
Enter fullscreen mode Exit fullscreen mode

๐ŸŽ›๏ธ How It Works

The code cycles through different task durations, with each one triggering a unique progress animation in the terminal:

  • x: Sets the task duration.
  • alive_bar(x): Initializes the progress bar.
  • bar(): Updates it each loop cycle.

Try experimenting with these values to see different speeds in action!

๐Ÿ“ธ Showcase

Hereโ€™s a snapshot of it in action:

Image1

Image2

๐Ÿ“ฃ Why Use It?

It makes waiting less boring and adds professionalism to your scripts. Try it out, and let me know what you think! Check out the official alive_progress GitHub page for more features.


Give it a try and enjoy coding with style! ๐Ÿ˜Ž

Top comments (0)