Skip to main content

A simple console-based loading bar for Python.

Project description

UltraEZLoadingBar

UltraEZLoadingBar is a simple Python package that displays a loading bar in the console.


Installation

To install the package, use pip:

pip install UltraEZLoadingBar

loading_bar Function

Purpose:

Displays a horizontal loading bar with optional color support and a customizable message.

Arguments:

  • steps (int): Total number of steps (e.g., iterations).
  • bar_length (int): The length of the loading bar in characters.
  • delay_per_step (float): The delay between each step (in seconds).
  • message (str): The message to display before the loading bar.
  • color (str): Optional. Adds color to the loading bar using ANSI escape codes. Examples: "r" (red), "g" (green), "b" (blue), etc.

Usage:

  1. Create a loading bar with 100 steps, 100 characters, a 0.1 second delay, and a red message:

    loading_bar(100, 100, 0.1, "Loading... ", "r")
    
  2. Create a loading bar with 100 steps, 100 characters, a 0.1 second delay, and a default color:

    loading_bar(100, 100, 0.1, "Processing... ")
    

    (If you don't want any color, omit the color argument, or pass "" for no text.)


enhancedloading_bar Function

Purpose:

Displays a horizontal loading bar with estimated time remaining.

Arguments:

  • steps (int): Total number of steps.
  • bar_length (int): The length of the loading bar in characters.
  • delay_per_step (float): The delay between each step (in seconds).
  • message (str): The message to display before the loading bar.
  • color (str): Optional. Adds color to the loading bar using ANSI escape codes. Examples: "r" (red), "g" (green), "b" (blue), etc.

Usage:

  1. Create a loading bar with 100 steps, 100 characters, a 0.1 second delay, and a red message:
    enhancedloading_bar(100, 100, 0.1, "Loading... ", "r")
    

new_line Function

Purpose:

Creates a new line in the console.

Usage:

new_line()

colored_text Function

Purpose:

Prints the given text in the specified color.

Arguments:

  • text (str): The text to be printed.
  • color (str): The color of the text. Available colors: "red", "green", "blue", "yellow", "magenta", "cyan", "white", etc.

Usage:

Print "Hello!" in blue:

colored_text("Hello!", "blue")

cls Function

Purpose:

Clears the console screen.

Usage:

cls()

generatekey Function

Purpose:

Returns:

  • A random key string (e.g., '...your_key...').

Usage:

key = generatekey()
print(key)

Output:


## version Function

### Purpose:
Returns the version of the UltraEZLoadingBar module as a string.

### Returns:
- **str**: The version of the module (e.g., `'0.0.0.7'`).

### Usage:
```python
from UltraEZLoadingBar import version
print(version())

Output:

UltraEZLoadingBar Version: 0.0.0.7

version Function

Purpose:

Returns the version of the UltraEZLoadingBar module as a string.

Returns:

  • str: The version of the module (e.g., '0.0.0.7').

Usage:

from UltraEZLoadingBar import version
print(version())

Output:

UltraEZLoadingBar Version: 0.0.0.7

Real Code Example:

import sys
import time
from cryptography.fernet import Fernet

# Color Stuff
def loading_bar(steps=50, bar_length=50, delay_per_step=0.1, message="Loading... ", color=None):
    # Define basic ANSI color codes
    colors = {
        "r": "\033[91m",
        "g": "\033[92m",
        "y": "\033[93m",
        "b": "\033[94m",
        "m": "\033[95m",
        "c": "\033[96m",
        "w": "\033[97m",
        "refresh": "\033[0m"
    }

    # Apply color if specified
    start_color = colors.get(color, "")  # Get the color code or empty string if invalid
    reset_color = colors["refresh"]

    for current_step in range(steps + 1):
        # Calculate progress
        filled_length = int((current_step / steps) * bar_length)
        bar = f"[{'=' * filled_length}{' ' * (bar_length - filled_length)}]"

        # Print the bar on the same line without adding extra lines
        sys.stdout.write(f"\r{start_color}{message}{bar} {current_step}/{steps}{reset_color}")
        sys.stdout.flush()
        time.sleep(delay_per_step)

    # Clear and overwrite the bar with a "Complete!" message
    sys.stdout.write("\n")

def enhancedloading_bar(steps=50, bar_length=50, delay_per_step=0.1, message="Loading...", color=None):
    """
    Displays a horizontal loading bar with estimated time remaining.
    """
    # Define basic ANSI color codes
    colors = {
        "r": "\033[91m",
        "g": "\033[92m",
        "y": "\033[93m",
        "b": "\033[94m",
        "m": "\033[95m",
        "c": "\033[96m",
        "w": "\033[97m",
        "refresh": "\033[0m"
    }

    # Apply color if specified
    start_color = colors.get(color, "")
    reset_color = colors["refresh"]

    start_time = time.time()

    for current_step in range(steps + 1):
        # Calculate progress
        filled_length = int((current_step / steps) * bar_length)
        bar = f"[{'=' * filled_length}{' ' * (bar_length - filled_length)}]"

        elapsed_time = time.time() - start_time
        eta = (elapsed_time / (current_step + 1)) * (steps - current_step) if current_step > 0 else 0

        # Print the bar with ETA
        sys.stdout.write(f"\r{start_color}{message}{bar} {current_step}/{steps} ETA: {eta:.1f}s{reset_color}")
        sys.stdout.flush()
        time.sleep(delay_per_step)

    sys.stdout.write("\nDone!\n")

def new_line():
    print("\n")

def colored_text(text, color):
    colors = {
        "red": "\033[91m",
        "green": "\033[92m",
        "yellow": "\033[93m",
        "blue": "\033[94m",
        "magenta": "\033[95m",
        "cyan": "\033[96m",
        "white": "\033[97m",
        "reset": "\033[0m"
    }

    color_code = colors.get(color.lower(), colors["white"])
    print(f"{color_code}{text}{colors['reset']}")

def cls():
    print("\033[H\033[J")

def generatekey():
    return Fernet.generate_key().decode()  # Decoding the byte key to a string

Changelog

Version 0.0.7

  • Added version function to return the module version.
  • Added a 5 version changelog
  • Added an error handler to the functions.

Version 0.0.6

  • Removed Devmode Function.
  • Added Enhanced Loading Bar
  • Added Key Generator

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

ultraezloadingbar-0.0.0.7.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ultraezloadingbar-0.0.0.7-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file ultraezloadingbar-0.0.0.7.tar.gz.

File metadata

  • Download URL: ultraezloadingbar-0.0.0.7.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ultraezloadingbar-0.0.0.7.tar.gz
Algorithm Hash digest
SHA256 947c5cb92aa3620cb82eaf6070360387b3e6677334ac7ebb024a7a81a664d094
MD5 459a469cd87a407b2bc1bc456e13ea5d
BLAKE2b-256 a4ff46bcba97ae5c321e5b15ffc7f7136306a974ed2a7f70e30960700180f57f

See more details on using hashes here.

File details

Details for the file ultraezloadingbar-0.0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for ultraezloadingbar-0.0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7e2ce69471ba0ca1536ca9aa57558b7af916ed92fee741273b693b4b5d19bff6
MD5 187412008fc25edf176dd54ea751cb41
BLAKE2b-256 254824e385ce99f809c6c97615fc8893d95d28ee5a6b8d9260b19584c630c34b

See more details on using hashes here.

Supported by

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