Skip to main content

An easy to use LoadingWindow for Apps that needs pre-setups

Project description

LoadingWindow

Hit the ⭐ at our repo if this helped!!!

Developed by LeeFuuChang © 2024

Examples of How To Use

Creating A LoadingWindow

from LoadingWindow import AbstractLoadingWindow

window = AbstractLoadingWindow()
window.exec_()

Add Tasks to load

from LoadingWindow import AbstractLoadingWindow

import time

def fakeTask(loadingwindow: AbstractLoadingWindow, percentage):
    try:
        loadingwindow.text = f"Loading... [{percentage} out of 100]" # update loading status text
        loadingwindow.progress = percentage # update loading progress-bar value [0, 100]
        time.sleep(0.1)
        return True # return True if the loading finished successfully
    except Exception as e:
        return False # return False if the loading failed (maybe due to connection-error or other issues...)

window = AbstractLoadingWindow()

# define the tasks to load in a list
tasksToLoad = [lambda p=i:fakeTask(window, p) for i in range(101)]

# Set the tasks to load
window.setTasks(tasksToLoad)
# Update loading status (text, progress) by passing the `window` into the function

window.exec_()

Task Function Structure

def fakeTask(loadingwindow: AbstractLoadingWindow, ...):
    """
    @params:
        loadingwindow: AbstractLoadingWindow
        > pass the window object in so you can update the loading status to your user

    @returns:
        bool
        > True -> task success
        > False -> task failed
    """
    try:
        # ... Do the Setup

        loadingwindow.text = "Describe the loading process to your user"
        loadingwindow.progress = 64 # loading progress (%) [0, 100]

        return True
    except Exception as e:
        # ... Handle the Error
        return False

Useful APIs

Set the Size of the loading Window

AbstractLoadingWindow.setSize(500, 300) # Width and Height

Set the Height of the ProgressBar

AbstractLoadingWindow.setBarHeight(30)

Set the Loading Status Text's FontSize

AbstractLoadingWindow.setFontSize(10)

Set distance between the Window's Edge and the ProgressBar

AbstractLoadingWindow.setPadding(30, 30) # Vertical and Horizontal

Set Loading Window FrameRate

AbstractLoadingWindow.setFrameRate(60)

Set Loading Window's Icon

this only works after packing into an executable

AbstractLoadingWindow.setIconPath("./Path/To/Your/Icon")

Set Loading Splash Image

AbstractLoadingWindow.setSplashArtPath("./Path/To/Your/Image")

Set Tasks to load

AbstractLoadingWindow.setTasks([])

Set Tasks retries

AbstractLoadingWindow.setRetries(3)

Set How long (in seconds) the loading windows stays after all tasks completed

AbstractLoadingWindow.setPreserveTime(1)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

LoadingWindow-1.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file LoadingWindow-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: LoadingWindow-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.9

File hashes

Hashes for LoadingWindow-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56a216ef584c2eaafdc058b292dc9d46e897973e81f46b375f95be6a74a96a74
MD5 0748779256dc08a9b6415cdbe6ee77f0
BLAKE2b-256 b240f3d32012add1843c59f29c6f2ed5c99621aff671746191bd70b07f7c4782

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