Skip to content

Commit c7b536a

Browse files
committed
Updated README
Signed-off-by: schlopp96 <71921821+schlopp96@users.noreply.github.com>
1 parent fb23d21 commit c7b536a

1 file changed

Lines changed: 58 additions & 56 deletions

File tree

README.md

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,33 @@
66

77
## About
88

9-
- Useful for small intermittant pauses between console text returns, or code actions.
9+
- Useful for small intermittent pauses between console text returns, or code actions.
1010

11-
- Customizable/optional loading and completion messages available to print to console (stdout).
11+
- Customizable/optional loading and completion messages are available to print to the console (stdout).
1212

13-
- Loading message defaults to `"Loading..."`.
14-
- Completion message defaults to `"Done!"`.
13+
- Messages can be customized by passing custom strings to the `msg_loading: str` and `msg_complete: str` parameters respectively.
1514

16-
- Includes an _optional_ progress meter (simply change the `enable_display: bool` parameter to `False` if you wish to disable the progress meter), toggled on by default.
15+
- The sequence loading message defaults to `"Loading..."`
16+
- The sequence completion message defaults to `"Done!"`
17+
18+
- You may apply a label to the progress bar using the `label: str` parameter (defaults to `None`).
19+
20+
- `enable_display: bool` must be set to `True` for a label to be assigned to the progress bar.
21+
22+
- The time taken to complete each iteration can be determined using the `min_iter: float` and `max_iter: float` parameters.
23+
24+
- Each iteration length is randomized to a value between `min_iter: float` and `max_iter: float` seconds.
25+
- e.g. `start(min_iter=0.5, max_iter=1.5)` would take anywhere between 0.5 - 1.5 seconds to complete a single iteration.
26+
27+
- Users can choose between two different loading sequences:
28+
**A.** Progress-bar style loading sequence
29+
**B.** Animated-text style loading sequence
30+
31+
- If `enable_display: bool` is `False, the progress-bar-based sequence will not be used, and the animated text-based loading sequence will be used instead.
32+
33+
- The desired loading sequence **can be toggled** using the `enable_display: bool` parameter.
34+
35+
- The text-based loading sequence displays the loading message followed by incrementing dots, all printed to the same line
1736

1837
---
1938

@@ -37,84 +56,67 @@
3756

3857
> _Not_ recommended.
3958
40-
1. Download source code `.zip` archive from the PyLoadBar GitHub [releases](https://github.com/schlopp96/PyLoadBar/releases/latest) page and extract contents to desired location.
59+
**1a.** Download the latest source code `.zip` archive from the PyLoadBar GitHub [releases](https://github.com/schlopp96/PyLoadBar/releases/latest) page and extract contents to the desired location.
4160

42-
- OR:
61+
- **OR:**
4362

44-
1. Clone repository with the git client of your preference with:
63+
**1b.** Clone repository with the git client of your preference with:
4564

46-
- `gh repo clone schlopp96/PyLoadBar`
65+
```shell
66+
gh repo clone schlopp96/PyLoadBar
67+
```
4768

48-
2. Navigate to directory containing extracted contents, and open said folder within a terminal.
69+
**2.** Navigate to the directory containing extracted contents, and open said folder within a terminal.
4970

50-
3. Enter `pip install -r requirements.txt` to install all dependencies for this package.
71+
**3.** Enter `pip install -r requirements.txt` to install all dependencies for this package.
5172

52-
4. Finally, move the `"PyLoadBar-vx.x.x"` directory to your global Python 3rd-party package installation directory to be able to import `PyLoadBar` like any other module:
73+
**4.** Finally, move the `"PyLoadBar-Vx.x.x"` directory to your global Python 3rd-party package installation directory to be able to import `PyLoadBar` like any other module:
5374

54-
- `"~Python/Lib/site-packages/HERE"`
75+
- `"~Python/Lib/site-packages/HERE"`
5576

56-
5. Done!
77+
**5.** Done!
5778

5879
---
5980

6081
## Usage
6182

62-
- Within a `.py` project, simply import the `PyLoadBar` module to start using your custom loading sequence.
63-
6483
- `PyLoadBar` is _very_ simple to use.
6584

66-
- For example, try running the following:
67-
68-
```python
69-
>>> from PyLoadBar import PyLoadBar
70-
71-
>>> bar = PyLoadBar() # Initialize a new `PyLoadBar` instance.
72-
73-
>>> def add50(x):
74-
bar.load(msg_loading='Adding 50 to x', msg_complete='Okay!', time=30, label='Solving', enable_display=True) # Call `load` method to start loading sequence.
75-
return x + 50
76-
77-
>>> print(add50(50))
78-
```
79-
80-
- This will return:
81-
82-
```python
83-
Adding 50 to x...
84-
85-
Solving: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<00:00, 8.94it/s].
85+
- Within a `.py` project, simply import the `PyLoadBar` module to start using your custom loading sequence.
8686

87-
Okay!
87+
- Example of standard loading sequence with `label` set to `'Solving'`:
8888

89-
100
90-
```
89+
```python
90+
>>> from PyLoadBar import PyLoadBar
9191

92-
- The **_loading_** and **_loading complete_** messages can be customized by passing custom strings to the `msg_loading: str` and `msg_complete: str` parameters respectively.
92+
>>> important_bar = PyLoadBar(msg_loading='Important Stuff Happening', msg_complete='Day Saved!', label='Saving Day') # Initialize a new `PyLoadBar` instance.
9393

94-
- Note that the progress bar **can be toggled** using the `enable_display: bool` parameter.
94+
>>> important_bar.start(min_iter=0.05, max_iter=1.0, iter_total=10) # Call `start` method to start loading sequence.
9595

96-
- The time taken to complete the loading sequence can be determined using the `time: int` parameter.
96+
Important Stuff Happening...
9797

98-
- Each unit of time is equivalent to 1/10th of a second.
99-
- Every 10 units = 1 second.
100-
- e.g. `load(time=5)` (default) would take 0.5 seconds to fill the progress bar.
98+
Saving Day: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10
10199

102-
- You may also label the progress bar with the `label: str` parameter (defaults to `None`).
100+
Day Saved!
101+
```
103102

104-
- Example:
103+
- Example of animated-text-based loading sequence:
105104

106105
```python
107-
>>> from PyLoadBar import PyLoadBar
106+
>>> from PyLoadBar import PyLoadBar
108107

109-
>>> important_bar = PyLoadBar() # Initialize a new `PyLoadBar` instance.
108+
>>> bar = PyLoadBar(msg_loading='Loading', msg_complete='Done!', enable_display=False) # Initialize loading sequence.
110109

111-
>>> important_bar.load('Important Stuff Happening', 'Day Saved!', 50, 'Saving Day') # Call `load` method to start loading sequence.
110+
>>> bar.start(iter_total=1) # Start animated-text loading sequence.
112111

113-
Important Stuff Happening...
112+
# Note that during actual use case, text is printed to same line followed by incrementing dots:
114113

115-
Saving Day: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [00:05<00:00, 9.19it/s]
114+
Loading
115+
Loading.
116+
Loading..
117+
Loading...
116118

117-
Day Saved!
119+
Done!
118120
```
119121

120122
---
@@ -123,9 +125,9 @@ Okay!
123125

124126
- If you wish to help contribute to this project, please run the following in your virtual env to acquire the necessary dependencies and tools you need to develop and run tests:
125127

126-
```python
127-
pip install PyLoadBar[dev]
128-
```
128+
```shell
129+
pip install PyLoadBar[dev]
130+
```
129131

130132
---
131133

0 commit comments

Comments
 (0)