strprogressbar


Namestrprogressbar JSON
Version 1.0 PyPI version JSON
download
home_pagehttps://github.com/SDeVuyst/strprogressbar
SummaryA simple python package to create Progress bars as Strings
upload_time2023-07-30 12:04:14
maintainer
docs_urlNone
authorSDeVuyst
requires_python
licenseGNU General Public License v3 (GPLv3)
keywords string progressbar progress bar
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center"><img src="https://socialify.git.ci/SDeVuyst/strprogressbar/image?description=1&font=Bitter&language=1&name=1&owner=1&pattern=Plus&theme=Dark" alt="project-image"></p>

<p align="center">
<a href='https://github.com/SDeVuyst/strprogressbar/issues'><img src="https://img.shields.io/github/issues/SDeVuyst/strprogressbar.svg"></a>
<a href="https://github.com/SDeVuyst/strprogressbar/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="shields"></a>
</p>

<h1>🚀 Usage</h1>

**_ProgressBar_** has quite a few parameters:
| Parameter name | Mandatory | Type | Description |
| --- | --- | --- | --- |
| `value` | **yes** | int | Current value of the progress bar
| `total` | **yes** | int | Max value of the progress bar
| `string_length` | **yes** | int | Length of the bar
| `unfilled_char` | no | str | char that displays the unfilled portion of the bar. Defaults to "▬".
| `progress_char` | no | str | char that displays the filled portion of the bar. Defaults to "🔘".
| `fill_bar` | no | bool | If the left side of the bar should also be filled. Defaults to False.

<h2>Examples: </h2>


```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 67/85
p = ProgressBar(67, 85, 25)
print(p)

>>> "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬"
```
```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 20 characters
# we are in step 3/5, change the default characters
# fill in the progress that we already made
p = ProgressBar(3, 5, 20, "░", "▓", True)
print(p)

>>> "▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░"
```
```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 30 characters
# we are in step 8/15, change the default characters
# fill in the progress that we already made with 2 chars
p = ProgressBar(8, 15, 30, "░", "▒▓", True)
print(p)

>>> "▒▓▒▓▒▓▒▓▒▓▒▓▒▓▒▓░░░░░░░░░░░░░░"
```

<h2>What if we want to show our progress in numbers or in percentage?</h2>

**_ProgressBar_** has 4 default functions to add or remove this feature.

- [add_percentage()](#add_percentage())
- [remove_percentage()](#remove_percentage())
- [add_counter()](#add_counter())
- [remove_counter()](#remove_counter())

Note that adding percentage or counter does not alter the size of the progress bar. eg: If you set `string_length` to 20 and added a percentage indicator, the progress bar will still be 20 chars long, but the total string will be longer with the percentage sign. 

<h3>add_percentage()</h3>
<h4>Parameters</h4>

| Parameter name | Mandatory | Type | Description |
| --- | --- | --- | --- |
| `decimals` | no | int | The amount of decimals to display. Defaults to 0.
| `left` | no | bool | If the percentage should be displayed to the left of the progress bar. Defaults to False/right side.
| `seperator` | no | str | The seperator between the progress bar and the percentage number. Defaults to " ".

<h4>Example</h4>

```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 30/64 and display this on the right side with 2 decimals
p = ProgressBar(30, 64, 25).add_percentage(2, False)
print(p)

>>> "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬ 46.88%"
    |__________________________|
            25 characters
```

<h3>remove_percentage()</h3>
<h4>Parameters</h4>

*This function has no parameters.*

<h4>Example</h4>

```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 30/64 and display this on the right side with 0 decimals
p = ProgressBar(30, 64, 25).add_percentage(0, False, ' @ ')
print(p)
# remove the percentage
print(p.remove_percentage())

>>> "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬ @ 47%"
>>> "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬"
```

<h3>add_counter()</h3>
<h4>Parameters</h4>

| Parameter name | Mandatory | Type | Description |
| --- | --- | --- | --- |
| `left` | no | bool | If the percentage should be displayed to the left of the progress bar. Defaults to False/right side.
| `seperator` | no | str |The seperator between the progress bar and the percentage number. Defaults to " "

<h4>Example</h4>

```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 67/85 and display this on the left side
p = ProgressBar(67, 85, 25).add_counter(True, " - ")
print(p)

>>> "67/85 - ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬"
```
We can also add both a counter and a percentage indicator:
```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 67/85 and display this on the left side
# add a percentage indicator on the right side
p = ProgressBar(67, 85, 25).add_counter(True, " - ").add_percentage(1, False, " - ")
print(p)

>>> "67/85 - ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬ - 78.8%"
```

<h3>remove_counter()</h3>
<h4>Parameters</h4>

*This function has no parameters.*

<h4>Example</h4>

```python
from strprogressbar import ProgressBar
# create a progressbar with a width of 25 characters
# we are in step 18/64 and display this on the right side with 0 decimals
p = ProgressBar(18, 64, 25, "░", "▓", True).add_counter(False).add_percentage()
print(p)
# remove the percentage
print(p.remove_counter())

>>> "▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░ 28% 18/64"

>>> "▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░ 28%"
```
  
<br>
<h1>🛠️ Installation Steps:</h1>

<p>1. Installing</p>

```
pip install strprogressbar
```
<br>
<h1>🛡️ License:</h1>

This project is licensed under the GNU General Public License v3.0

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SDeVuyst/strprogressbar",
    "name": "strprogressbar",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "string,progressbar,progress,bar",
    "author": "SDeVuyst",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/70/a0/5e5b0b81cdaa379fafcf93764059941a71079095dbd1a709cfc21a7af51e/strprogressbar-1.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\"><img src=\"https://socialify.git.ci/SDeVuyst/strprogressbar/image?description=1&font=Bitter&language=1&name=1&owner=1&pattern=Plus&theme=Dark\" alt=\"project-image\"></p>\r\n\r\n<p align=\"center\">\r\n<a href='https://github.com/SDeVuyst/strprogressbar/issues'><img src=\"https://img.shields.io/github/issues/SDeVuyst/strprogressbar.svg\"></a>\r\n<a href=\"https://github.com/SDeVuyst/strprogressbar/blob/main/LICENSE\"><img src=\"https://img.shields.io/badge/License-GPLv3-blue.svg\" alt=\"shields\"></a>\r\n</p>\r\n\r\n<h1>\ud83d\ude80 Usage</h1>\r\n\r\n**_ProgressBar_** has quite a few parameters:\r\n| Parameter name | Mandatory | Type | Description |\r\n| --- | --- | --- | --- |\r\n| `value` | **yes** | int | Current value of the progress bar\r\n| `total` | **yes** | int | Max value of the progress bar\r\n| `string_length` | **yes** | int | Length of the bar\r\n| `unfilled_char` | no | str | char that displays the unfilled portion of the bar. Defaults to \"\u25ac\".\r\n| `progress_char` | no | str | char that displays the filled portion of the bar. Defaults to \"\ud83d\udd18\".\r\n| `fill_bar` | no | bool | If the left side of the bar should also be filled. Defaults to False.\r\n\r\n<h2>Examples: </h2>\r\n\r\n\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 25 characters\r\n# we are in step 67/85\r\np = ProgressBar(67, 85, 25)\r\nprint(p)\r\n\r\n>>> \"\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\ud83d\udd18\u25ac\u25ac\u25ac\u25ac\u25ac\"\r\n```\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 20 characters\r\n# we are in step 3/5, change the default characters\r\n# fill in the progress that we already made\r\np = ProgressBar(3, 5, 20, \"\u2591\", \"\u2593\", True)\r\nprint(p)\r\n\r\n>>> \"\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\"\r\n```\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 30 characters\r\n# we are in step 8/15, change the default characters\r\n# fill in the progress that we already made with 2 chars\r\np = ProgressBar(8, 15, 30, \"\u2591\", \"\u2592\u2593\", True)\r\nprint(p)\r\n\r\n>>> \"\u2592\u2593\u2592\u2593\u2592\u2593\u2592\u2593\u2592\u2593\u2592\u2593\u2592\u2593\u2592\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\"\r\n```\r\n\r\n<h2>What if we want to show our progress in numbers or in percentage?</h2>\r\n\r\n**_ProgressBar_** has 4 default functions to add or remove this feature.\r\n\r\n- [add_percentage()](#add_percentage())\r\n- [remove_percentage()](#remove_percentage())\r\n- [add_counter()](#add_counter())\r\n- [remove_counter()](#remove_counter())\r\n\r\nNote that adding percentage or counter does not alter the size of the progress bar. eg: If you set `string_length` to 20 and added a percentage indicator, the progress bar will still be 20 chars long, but the total string will be longer with the percentage sign. \r\n\r\n<h3>add_percentage()</h3>\r\n<h4>Parameters</h4>\r\n\r\n| Parameter name | Mandatory | Type | Description |\r\n| --- | --- | --- | --- |\r\n| `decimals` | no | int | The amount of decimals to display. Defaults to 0.\r\n| `left` | no | bool | If the percentage should be displayed to the left of the progress bar. Defaults to False/right side.\r\n| `seperator` | no | str | The seperator between the progress bar and the percentage number. Defaults to \" \".\r\n\r\n<h4>Example</h4>\r\n\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 25 characters\r\n# we are in step 30/64 and display this on the right side with 2 decimals\r\np = ProgressBar(30, 64, 25).add_percentage(2, False)\r\nprint(p)\r\n\r\n>>> \"\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\ud83d\udd18\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac 46.88%\"\r\n    |__________________________|\r\n            25 characters\r\n```\r\n\r\n<h3>remove_percentage()</h3>\r\n<h4>Parameters</h4>\r\n\r\n*This function has no parameters.*\r\n\r\n<h4>Example</h4>\r\n\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 25 characters\r\n# we are in step 30/64 and display this on the right side with 0 decimals\r\np = ProgressBar(30, 64, 25).add_percentage(0, False, ' @ ')\r\nprint(p)\r\n# remove the percentage\r\nprint(p.remove_percentage())\r\n\r\n>>> \"\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\ud83d\udd18\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac @ 47%\"\r\n>>> \"\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\ud83d\udd18\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\"\r\n```\r\n\r\n<h3>add_counter()</h3>\r\n<h4>Parameters</h4>\r\n\r\n| Parameter name | Mandatory | Type | Description |\r\n| --- | --- | --- | --- |\r\n| `left` | no | bool | If the percentage should be displayed to the left of the progress bar. Defaults to False/right side.\r\n| `seperator` | no | str |The seperator between the progress bar and the percentage number. Defaults to \" \"\r\n\r\n<h4>Example</h4>\r\n\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 25 characters\r\n# we are in step 67/85 and display this on the left side\r\np = ProgressBar(67, 85, 25).add_counter(True, \" - \")\r\nprint(p)\r\n\r\n>>> \"67/85 - \u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\ud83d\udd18\u25ac\u25ac\u25ac\u25ac\u25ac\"\r\n```\r\nWe can also add both a counter and a percentage indicator:\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 25 characters\r\n# we are in step 67/85 and display this on the left side\r\n# add a percentage indicator on the right side\r\np = ProgressBar(67, 85, 25).add_counter(True, \" - \").add_percentage(1, False, \" - \")\r\nprint(p)\r\n\r\n>>> \"67/85 - \u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\u25ac\ud83d\udd18\u25ac\u25ac\u25ac\u25ac\u25ac - 78.8%\"\r\n```\r\n\r\n<h3>remove_counter()</h3>\r\n<h4>Parameters</h4>\r\n\r\n*This function has no parameters.*\r\n\r\n<h4>Example</h4>\r\n\r\n```python\r\nfrom strprogressbar import ProgressBar\r\n# create a progressbar with a width of 25 characters\r\n# we are in step 18/64 and display this on the right side with 0 decimals\r\np = ProgressBar(18, 64, 25, \"\u2591\", \"\u2593\", True).add_counter(False).add_percentage()\r\nprint(p)\r\n# remove the percentage\r\nprint(p.remove_counter())\r\n\r\n>>> \"\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 28% 18/64\"\r\n\r\n>>> \"\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 28%\"\r\n```\r\n  \r\n<br>\r\n<h1>\ud83d\udee0\ufe0f Installation Steps:</h1>\r\n\r\n<p>1. Installing</p>\r\n\r\n```\r\npip install strprogressbar\r\n```\r\n<br>\r\n<h1>\ud83d\udee1\ufe0f License:</h1>\r\n\r\nThis project is licensed under the GNU General Public License v3.0\r\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 (GPLv3)",
    "summary": "A simple python package to create Progress bars as Strings",
    "version": "1.0",
    "project_urls": {
        "Download": "https://github.com/SDeVuyst/strprogressbar/archive/refs/tags/v_1.0.tar.gz",
        "Homepage": "https://github.com/SDeVuyst/strprogressbar"
    },
    "split_keywords": [
        "string",
        "progressbar",
        "progress",
        "bar"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "70a05e5b0b81cdaa379fafcf93764059941a71079095dbd1a709cfc21a7af51e",
                "md5": "ffeef3f14f31a9646c819813770c0b72",
                "sha256": "7d5b481175aaaf97bdf4f17318368c299faea23ceb0fb3c2f4ecf6d760243d57"
            },
            "downloads": -1,
            "filename": "strprogressbar-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ffeef3f14f31a9646c819813770c0b72",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 17015,
            "upload_time": "2023-07-30T12:04:14",
            "upload_time_iso_8601": "2023-07-30T12:04:14.401866Z",
            "url": "https://files.pythonhosted.org/packages/70/a0/5e5b0b81cdaa379fafcf93764059941a71079095dbd1a709cfc21a7af51e/strprogressbar-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-30 12:04:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SDeVuyst",
    "github_project": "strprogressbar",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "strprogressbar"
}
        
Elapsed time: 0.09309s