mirror of
https://github.com/verigak/progress.git
synced 2025-12-10 12:15:34 +00:00
README.rst: Syntax highlight Python code
Works on both GitHub and PyPI (after you do `python setup.py register`)
This commit is contained in:
26
README.rst
26
README.rst
@@ -13,7 +13,9 @@ There are 6 progress bars to choose from:
|
|||||||
- IncrementalBar
|
- IncrementalBar
|
||||||
- ShadyBar
|
- ShadyBar
|
||||||
|
|
||||||
To use them, just call ``next`` to advance and ``finish`` to finish. ::
|
To use them, just call ``next`` to advance and ``finish`` to finish:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
from progress.bar import Bar
|
from progress.bar import Bar
|
||||||
|
|
||||||
@@ -28,13 +30,17 @@ The result will be a bar like the following: ::
|
|||||||
Processing |############# | 42/100
|
Processing |############# | 42/100
|
||||||
|
|
||||||
To simplify the common case where the work is done in an iterator, you can
|
To simplify the common case where the work is done in an iterator, you can
|
||||||
use the ``iter`` method. ::
|
use the ``iter`` method:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
for i in Bar('Processing').iter(it):
|
for i in Bar('Processing').iter(it):
|
||||||
# Do some work
|
# Do some work
|
||||||
|
|
||||||
Progress bars are very customizable, you can change their width, their fill
|
Progress bars are very customizable, you can change their width, their fill
|
||||||
character, their suffix and more. ::
|
character, their suffix and more:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
bar = Bar('Loading', fill='@', suffix='%(percent)d%%')
|
bar = Bar('Loading', fill='@', suffix='%(percent)d%%')
|
||||||
|
|
||||||
@@ -60,14 +66,18 @@ eta_td eta as a timedelta (useful for printing as a string)
|
|||||||
========== ================================
|
========== ================================
|
||||||
|
|
||||||
Instead of passing all configuration options on instatiation, you can create
|
Instead of passing all configuration options on instatiation, you can create
|
||||||
your custom subclass. ::
|
your custom subclass:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
class FancyBar(Bar):
|
class FancyBar(Bar):
|
||||||
message = 'Loading'
|
message = 'Loading'
|
||||||
fill = '*'
|
fill = '*'
|
||||||
suffix = '%(percent).1f%% - %(eta)ds'
|
suffix = '%(percent).1f%% - %(eta)ds'
|
||||||
|
|
||||||
You can also override any of the arguments or create your own. ::
|
You can also override any of the arguments or create your own:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
class SlowBar(Bar):
|
class SlowBar(Bar):
|
||||||
suffix = '%(remaining_hours)d hours remaining'
|
suffix = '%(remaining_hours)d hours remaining'
|
||||||
@@ -79,7 +89,9 @@ You can also override any of the arguments or create your own. ::
|
|||||||
Spinners
|
Spinners
|
||||||
========
|
========
|
||||||
|
|
||||||
For actions with an unknown number of steps you can use a spinner. ::
|
For actions with an unknown number of steps you can use a spinner:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
from progress.spinner import Spinner
|
from progress.spinner import Spinner
|
||||||
|
|
||||||
@@ -98,5 +110,5 @@ There are 4 predefined spinners:
|
|||||||
Other
|
Other
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Thera are a number of other classes available too, please check the source or
|
There are a number of other classes available too, please check the source or
|
||||||
subclass one of them to create your own.
|
subclass one of them to create your own.
|
||||||
|
|||||||
Reference in New Issue
Block a user