# LoadingWindow
<h1 align="center"><img src="demo.png" width="300"></h1>
Hit the ⭐ at our [repo](https://github.com/LeeFuuChang/PyPI-LoadingWindow) if this helped!!!
[![PyPI Downloads](https://img.shields.io/pypi/dm/LoadingWindow?label=PyPI%20downloads)](https://pypi.org/project/LoadingWindow/) [![Downloads](https://static.pepy.tech/badge/LoadingWindow)](http://pepy.tech/project/LoadingWindow) [![PyPI Latest Release](https://img.shields.io/pypi/v/LoadingWindow)](https://pypi.org/project/LoadingWindow/) [![License - MIT](https://img.shields.io/pypi/l/LoadingWindow)](https://github.com/LeeFuuChang/PyPI-LoadingWindow/blob/main/LICENSE)
Developed by LeeFuuChang © 2024
## Install
```sh
pip3 install --upgrade LoadingWindow
```
## Quick Demo
```sh
python3 -m LoadingWindow
```
## Examples of How To Use
##### Creating A LoadingWindow
```python
from LoadingWindow import LoadingWindow
window = LoadingWindow()
window.exec_()
```
##### Add Tasks to load
```python
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_()
```
## Task Function Structure
```python
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 False
```
## Useful APIs
### LoadingWindow
##### Set the Size of the loading Window:
```python
LoadingWindow.setSize(500, 300) # Width and Height
```
##### Set distance between the Window's Edge and the ProgressBar:
```python
LoadingWindow.setPadding(30, 30) # Vertical and Horizontal
```
##### Set the Height of the ProgressBar:
```python
LoadingWindow.setBarHeight(24)
```
##### Set the Loading Status Text's FontSize:
```python
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-render
```
##### Set the Loading Status Text's FontColor:
```python
LoadingWindow.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-render
```
##### Set Loading Window's Icon:
> this only works after packing into an executable
```python
LoadingWindow.setIconPath("./Path/To/Your/Icon") # by path
LoadingWindow.setIconURL("./URL/To/Your/Icon") # by url
```
##### Set Loading Splash Image:
```python
LoadingWindow.setSplashArtPath("./Path/To/Your/Image") # by path
LoadingWindow.setSplashArtURL("./URL/To/Your/Image") # by url
```
##### Set Loading Window FrameRate:
```python
LoadingWindow.setFrameRate(30)
```
##### Set How long (in seconds) the loading windows stays after all tasks completed:
```python
LoadingWindow.setPreserveTime(1)
```
##### Set Tasks to load:
```python
LoadingWindow.setTasks([func1, func2, ...])
```
##### Set Tasks retries:
```python
LoadingWindow.setTaskRetries(3)
```
### ProgressBar
You can access `ProgressBar` instance by `LoadingWindow.progressBar`
##### Set the Loading Status Text
```python
ProgressBar.setText("Loading . . .") # this will auto re-render
# or
LoadingWindow.progressBar.text = "Loading . . ."
LoadingWindow.progressBar.updateStyle() # re-render
```
##### Set the Loading Progress Value
```python
ProgressBar.setProgress(0) # 0 ~ 100 # this will auto re-render
# or
LoadingWindow.progressBar.progress = 0 # 0 ~ 100
LoadingWindow.progressBar.updateStyle() # re-render
```
##### Set the Padding of ProgressBar Text
> this changes including status text and progress text
```python
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-render
```
##### Set the ProgressBar Text's FontSize:
```python
ProgressBar.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-render
```
##### Set the ProgressBar Text's FontColor:
```python
ProgressBar.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-render
```
##### Set the ProgressBar filled area's Color
```python
ProgressBar.setFilledColor("#69ca67")
```
##### Set the ProgressBar track's Color
```python
ProgressBar.setBackgroundColor("#ffffff")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/LeeFuuChang/PyPi-LoadingWindow",
"name": "LoadingWindow",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, python3, PyQt5, Loading Window",
"author": "LeeFuuChang",
"author_email": "a0962014248gg@gmail.com",
"download_url": null,
"platform": null,
"description": "\n# LoadingWindow\n\n<h1 align=\"center\"><img src=\"demo.png\" width=\"300\"></h1>\n\nHit the \u2b50 at our [repo](https://github.com/LeeFuuChang/PyPI-LoadingWindow) if this helped!!!\n\n[![PyPI Downloads](https://img.shields.io/pypi/dm/LoadingWindow?label=PyPI%20downloads)](https://pypi.org/project/LoadingWindow/) [![Downloads](https://static.pepy.tech/badge/LoadingWindow)](http://pepy.tech/project/LoadingWindow) [![PyPI Latest Release](https://img.shields.io/pypi/v/LoadingWindow)](https://pypi.org/project/LoadingWindow/) [![License - MIT](https://img.shields.io/pypi/l/LoadingWindow)](https://github.com/LeeFuuChang/PyPI-LoadingWindow/blob/main/LICENSE)\n\nDeveloped by LeeFuuChang \u00a9 2024\n\n## Install\n```sh\npip3 install --upgrade LoadingWindow\n```\n\n## Quick Demo\n```sh\npython3 -m LoadingWindow\n```\n\n## Examples of How To Use\n\n##### Creating A LoadingWindow\n```python\nfrom LoadingWindow import LoadingWindow\n\nwindow = LoadingWindow()\nwindow.exec_()\n```\n\n##### Add Tasks to load\n```python\nfrom LoadingWindow import LoadingWindow\n\nimport time\n\ndef fakeTask(loadingwindow: LoadingWindow, percentage):\n try:\n loadingwindow.text = f\"Loading... [{percentage} out of 100]\" # update loading status text\n loadingwindow.progress = percentage # update loading progress-bar value [0, 100]\n time.sleep(0.1)\n return True # return True if the loading finished successfully\n except Exception as e:\n return False # return False if the loading failed (maybe due to connection-error or other issues...)\n\nwindow = LoadingWindow()\n\n# define the tasks to load in a list\ntasksToLoad = [lambda p=i:fakeTask(window, p) for i in range(101)]\n\n# Set the tasks to load\nwindow.setTasks(tasksToLoad)\n# Update loading status (text, progress) by passing the `window` into the function\n\nwindow.exec_()\n```\n\n\n## Task Function Structure\n```python\ndef fakeTask(loadingwindow: LoadingWindow, ...):\n \"\"\"\n @params:\n loadingwindow: LoadingWindow\n > pass the window object in so you can update the loading status to your user\n\n @returns:\n bool\n > True -> task success\n > False -> task failed\n \"\"\"\n try:\n # ... Do the Setup\n\n loadingwindow.text = \"Describe the loading process to your user\"\n loadingwindow.progress = 64 # loading progress (%) [0, 100]\n\n return True\n except Exception as e:\n # ... Handle the Error\n return False\n```\n\n\n## Useful APIs\n\n### LoadingWindow\n\n##### Set the Size of the loading Window:\n```python\nLoadingWindow.setSize(500, 300) # Width and Height\n```\n\n##### Set distance between the Window's Edge and the ProgressBar:\n```python\nLoadingWindow.setPadding(30, 30) # Vertical and Horizontal\n```\n\n##### Set the Height of the ProgressBar:\n```python\nLoadingWindow.setBarHeight(24)\n```\n\n##### Set the Loading Status Text's FontSize:\n```python\nLoadingWindow.setFontSize(10) # this will auto re-render\n# or\nLoadingWindow.progressBar.setFontSize(10) # this will auto re-render\n# or\nLoadingWindow.progressBar.fontSize = 10\nLoadingWindow.progressBar.updateStyle() # re-render\n```\n\n##### Set the Loading Status Text's FontColor:\n```python\nLoadingWindow.setFontColor(\"#000000\") # this will auto re-render\n# or\nLoadingWindow.progressBar.setFontColor(\"#000000\") # this will auto re-render\n# or\nLoadingWindow.progressBar.fontColor = \"#000000\"\nLoadingWindow.progressBar.updateStyle() # re-render\n```\n\n##### Set Loading Window's Icon:\n> this only works after packing into an executable\n```python\nLoadingWindow.setIconPath(\"./Path/To/Your/Icon\") # by path\nLoadingWindow.setIconURL(\"./URL/To/Your/Icon\") # by url\n```\n\n##### Set Loading Splash Image:\n```python\nLoadingWindow.setSplashArtPath(\"./Path/To/Your/Image\") # by path\nLoadingWindow.setSplashArtURL(\"./URL/To/Your/Image\") # by url\n```\n\n##### Set Loading Window FrameRate:\n```python\nLoadingWindow.setFrameRate(30)\n```\n\n##### Set How long (in seconds) the loading windows stays after all tasks completed:\n```python\nLoadingWindow.setPreserveTime(1)\n```\n\n##### Set Tasks to load:\n```python\nLoadingWindow.setTasks([func1, func2, ...])\n```\n\n##### Set Tasks retries:\n```python\nLoadingWindow.setTaskRetries(3)\n```\n\n### ProgressBar\nYou can access `ProgressBar` instance by `LoadingWindow.progressBar`\n\n##### Set the Loading Status Text\n```python\nProgressBar.setText(\"Loading . . .\") # this will auto re-render\n# or\nLoadingWindow.progressBar.text = \"Loading . . .\"\nLoadingWindow.progressBar.updateStyle() # re-render\n```\n\n##### Set the Loading Progress Value\n```python\nProgressBar.setProgress(0) # 0 ~ 100 # this will auto re-render\n# or\nLoadingWindow.progressBar.progress = 0 # 0 ~ 100\nLoadingWindow.progressBar.updateStyle() # re-render\n```\n\n##### Set the Padding of ProgressBar Text\n> this changes including status text and progress text\n```python\nProgressBar.setPadding(0, 16) # Vertical and Horizontal # this will auto re-render\n# or\nLoadingWindow.progressBar.padding = (0, 16) # Vertical and Horizontal\nLoadingWindow.progressBar.updateStyle() # re-render\n```\n\n##### Set the ProgressBar Text's FontSize:\n```python\nProgressBar.setFontSize(10) # this will auto re-render\n# or\nLoadingWindow.setFontSize(10) # this will auto re-render\n# or\nLoadingWindow.progressBar.fontSize = 10\nLoadingWindow.progressBar.updateStyle() # re-render\n```\n\n##### Set the ProgressBar Text's FontColor:\n```python\nProgressBar.setFontColor(\"#000000\") # this will auto re-render\n# or\nLoadingWindow.setFontColor(\"#000000\") # this will auto re-render\n# or\nLoadingWindow.progressBar.fontColor = \"#000000\"\nLoadingWindow.progressBar.updateStyle() # re-render\n```\n\n##### Set the ProgressBar filled area's Color\n```python\nProgressBar.setFilledColor(\"#69ca67\")\n```\n\n##### Set the ProgressBar track's Color\n```python\nProgressBar.setBackgroundColor(\"#ffffff\")\n```\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An easy to use LoadingWindow for Apps that needs pre-setups",
"version": "3.1.2",
"project_urls": {
"Homepage": "https://github.com/LeeFuuChang/PyPi-LoadingWindow",
"Source": "https://github.com/LeeFuuChang/PyPi-LoadingWindow",
"Tracker": "https://github.com/LeeFuuChang/PyPi-LoadingWindow/issues"
},
"split_keywords": [
"python",
" python3",
" pyqt5",
" loading window"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fdfd2978721ff219042c67a57a9a9b5cfb5d0b2450b9bde058d5978ad000a07f",
"md5": "9355af542560f07072a9449cea0c5108",
"sha256": "fb19a134f359bf3553a150644d35f49445661cbab1bf4310b9acb810a8f39a5f"
},
"downloads": -1,
"filename": "LoadingWindow-3.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9355af542560f07072a9449cea0c5108",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8143,
"upload_time": "2024-07-25T10:29:08",
"upload_time_iso_8601": "2024-07-25T10:29:08.695625Z",
"url": "https://files.pythonhosted.org/packages/fd/fd/2978721ff219042c67a57a9a9b5cfb5d0b2450b9bde058d5978ad000a07f/LoadingWindow-3.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-25 10:29:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LeeFuuChang",
"github_project": "PyPi-LoadingWindow",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "loadingwindow"
}