Hit the ⭐ at our repo if this helped!!!
Developed by LeeFuuChang © 2024
pip3 install --upgrade LoadingWindowpython3 -m LoadingWindowfrom LoadingWindow import LoadingWindow
window = LoadingWindow()
window.exec_()from LoadingWindow import LoadingWindow
import time
def fakeTask(loadingwindow: LoadingWindow, 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 = LoadingWindow()
# 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_()def fakeTask(loadingwindow: LoadingWindow, ...):
"""
@params:
loadingwindow: LoadingWindow
> 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 FalseLoadingWindow.setSize(500, 300) # Width and HeightLoadingWindow.setPadding(30, 30) # Vertical and HorizontalLoadingWindow.setBarHeight(24)LoadingWindow.setFontSize(10) # this will auto re-render
# or
LoadingWindow.progressBar.setFontSize(10) # this will auto re-render
# or
LoadingWindow.progressBar.fontSize = 10
LoadingWindow.progressBar.updateStyle() # re-renderLoadingWindow.setFontColor("#000000") # this will auto re-render
# or
LoadingWindow.progressBar.setFontColor("#000000") # this will auto re-render
# or
LoadingWindow.progressBar.fontColor = "#000000"
LoadingWindow.progressBar.updateStyle() # re-renderthis only works after packing into an executable
LoadingWindow.setIconPath("./Path/To/Your/Icon") # by path
LoadingWindow.setIconURL("./URL/To/Your/Icon") # by urlLoadingWindow.setSplashArtPath("./Path/To/Your/Image") # by path
LoadingWindow.setSplashArtURL("./URL/To/Your/Image") # by urlLoadingWindow.setFrameRate(30)LoadingWindow.setPreserveTime(1)LoadingWindow.setTasks([func1, func2, ...])LoadingWindow.setTaskRetries(3)You can access ProgressBar instance by LoadingWindow.progressBar
ProgressBar.setText("Loading . . .") # this will auto re-render
# or
LoadingWindow.progressBar.text = "Loading . . ."
LoadingWindow.progressBar.updateStyle() # re-renderProgressBar.setProgress(0) # 0 ~ 100 # this will auto re-render
# or
LoadingWindow.progressBar.progress = 0 # 0 ~ 100
LoadingWindow.progressBar.updateStyle() # re-renderthis changes including status text and progress text
ProgressBar.setPadding(0, 16) # Vertical and Horizontal # this will auto re-render
# or
LoadingWindow.progressBar.padding = (0, 16) # Vertical and Horizontal
LoadingWindow.progressBar.updateStyle() # re-renderProgressBar.setFontSize(10) # this will auto re-render
# or
LoadingWindow.setFontSize(10) # this will auto re-render
# or
LoadingWindow.progressBar.fontSize = 10
LoadingWindow.progressBar.updateStyle() # re-renderProgressBar.setFontColor("#000000") # this will auto re-render
# or
LoadingWindow.setFontColor("#000000") # this will auto re-render
# or
LoadingWindow.progressBar.fontColor = "#000000"
LoadingWindow.progressBar.updateStyle() # re-renderProgressBar.setFilledColor("#69ca67")ProgressBar.setBackgroundColor("#ffffff")