Skip to main content

Customizeable loading sequence/progress bar generator, enabling users to customize start/finish messages, toggle sequence type, and set total iterations among other features.

Project description

PyLoadBar

Customizeable loading sequence/progress bar generator, enabling users to customize start/finish messages, toggle sequence type, and set total iterations among other features.


About

  • Useful for small intermittent pauses between console text returns, or visualizing the progress of a long-running process.

  • Users can choose between two different loading sequences:

    • A. Progress-bar style loading sequence
    • B. Animated-text style loading sequence
  • When instantiating a PyLoadBar object, you may set the type of loading sequence using the bar_sequence: bool parameter.

  • Once initialized, run the loading sequence using the start() method, and set sequence configuration using parameters.

  • Messages can be customized by passing custom strings to the msg_loading: str and msg_complete: str parameters respectively.

    • The loading message defaults to "Loading..."
    • The completion message defaults to "Done!"
  • You may apply a label to the progress bar using the label: str parameter (defaults to None).

    • NOTE: bar_sequence: bool must be set to True for a label to be assigned to the progress bar.

    • If bar_sequence: bool is False, the progress-bar sequence will not be used, and the animated text-based loading sequence will be used instead.

  • When calling the start() method and using the progress-bar sequence, the time taken to complete each iteration can be determined using the min_iter: float and max_iter: float parameters.

    • Each iteration length is randomized to a value between min_iter: float and max_iter: float seconds.
      • e.g. start(min_iter=0.5, max_iter=1.5) would take anywhere between 0.5 - 1.5 seconds to complete a single iteration.
  • The text-based loading sequence displays the loading message followed by incrementing dots, all printed to the same line.

    • Set number of seconds to complete a single text-sequence iteration using txt_seq_speed: float.
      • Defaults to 0.5 seconds per animation cycle.

Installing PyLoadBar

Using pip

Easiest method. Highly recommended over manual installation.

  • Run the following to install:

    pip install PyLoadBar
    
  • You should now be able to import PyLoadBar directly to your application.


Manual Installation

Not recommended.

1a. Download the latest source code .zip archive from the PyLoadBar GitHub releases page and extract contents to the desired location.

  • OR:

1b. Clone repository with the git client of your preference with:

gh repo clone schlopp96/PyLoadBar

2. Navigate to the directory containing extracted contents, and open said folder within a terminal.

3. Enter pip install -r requirements.txt to install all dependencies for this package.

4. Finally, move the "PyLoadBar-Vx.x.x" directory to your global Python 3rd-party package installation directory to be able to import PyLoadBar like any other module:

  • "~Python/Lib/site-packages/HERE"

5. Done!


Usage

  • PyLoadBar is very simple to use.

  • Within a .py project, simply import the PyLoadBar module to start using your custom loading sequence.

  • Example of standard loading sequence with label set to 'Solving':

      >>> from PyLoadBar import PyLoadBar
    
      >>> important_bar = PyLoadBar() # Initialize a new `PyLoadBar` instance.
    
      >>> important_bar.start(msg_loading='Important Stuff Happening', msg_complete='Day Saved!', label='Saving Day', min_iter=0.05, max_iter=1.0, iter_total=10) # Call `start` method to begin loading sequence.
    
      Important Stuff Happening...
    
      Saving Day: 100%|âˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆâˆ| 10/10
    
      Day Saved!
    
  • Example of animated-text-based loading sequence:

      >>> from PyLoadBar import PyLoadBar
    
      >>> bar = PyLoadBar(bar_sequence=False) # Initialize loading sequence.
    
      >>> bar.start(msg_loading='Loading', msg_complete='Done!', iter_total=1, txt_iter_speed=1) # Start animated-text loading sequence.
    
      # Note that during actual use case, text is printed to same line followed by incrementing dots:
    
      Loading
      Loading.
      Loading..
      Loading...
    
      Done!
    

Contributing to PyLoadBar

  • If you wish to help contribute to this project, please run the following in your virtual env to acquire the necessary dependencies and tools you need to develop and run tests:

      pip install PyLoadBar[dev]
    

Contact

  • If you have any questions, comments, or concerns that cannot be addressed through the project's GitHub repository, please feel free to contact me through my email address:

    • schloppdaddy@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyLoadBar-0.1.1.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

PyLoadBar-0.1.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file PyLoadBar-0.1.1.tar.gz.

File metadata

  • Download URL: PyLoadBar-0.1.1.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for PyLoadBar-0.1.1.tar.gz
Algorithm Hash digest
SHA256 42a25db011257d4c64ed9f46e570ebeea4bce8c442ebee31b0350c4d95f1d944
MD5 d0d4758fde99ee69d0fc07708657fd34
BLAKE2b-256 ec4e5e93b9072716efbc9cdd1a5603e9137ea0982a7ea90756d4cce74cf3d951

See more details on using hashes here.

Provenance

File details

Details for the file PyLoadBar-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: PyLoadBar-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for PyLoadBar-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dfcd2d8aee5bd91c3fc512694784bb4d510cd6b6d083bae77fc8aa24cc1bd6a3
MD5 84dd4765c93dc0f62e774926af604931
BLAKE2b-256 ed7f1abd5fcb5c4a6dd612eeece04d328ccd4d40f01f5875980e3142e9189be8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page