Effortlessly spice up your terminal apps using colors, progressbars & more
Project description
Revel
revel
helps you create beautiful interfaces for your command line tools. Best
of all, it's extremely easy to use.
Simply replace the standard print
function with revel's and just like that you
can now display colors!
from revel import print
print('[green]Hello, World![/]')
Styles
revel
uses BBCode-style markup to style your text. A variety of styles
are available:
-
Formatting:
- bold
- dim
- italic
- underlined
- inverted
- strikethrough
-
Text Colors:
- black
- red
- green
- blue
- magenta
- cyan
- white
-
Background Colors:
- bg-black
- bg-red
- bg-green
- bg-blue
- bg-magenta
- bg-cyan
- bg-white
Adding weak
to a tag will only apply the styles of that tag, if no competing styles are already applied. For example:
print("[red]Hello, [weak blue underlined]World![/][/]")
This will be displayed entirely in red (since the weak "blue" formatting is overridden by "red"), but the "underlined" formatting will still be applied.
Progressbars
Adding progressbars is easy as can be:
from revel import print, ProgressBar
import time
with ProgressBar(max=10, unit="percent") as bar:
for ii in range(10):
bar.progress = ii
time.sleep(1.0)
You can switch units between "count", "percent", "byte" and "time". The bar will also automatically display how much time remains until completion, once it is confident in its estimate.
Edit text after it has already been printed
Docked widgets can be edited at will. For example, this example docks a text line and updates it repeatedly:
from revel import print
import time
line = print("Looking for files", dock=True)
for ii in range(1, 10):
line.text = f"Found {ii} file(s)"
time.sleep(1.0)
Additional print
-like methods
In addition to print
, revel also provides success
, warning
, error
and
fatal
. These will be displayed in color, drawing attention to the message.
TODO
- Implement the
verbatim
tag - Jupyter Notebook support
- Test on bad terminals
- Actual docs
- Showcase features:
print_chapter
select
select_multiple
select_short
select_yes_no
input_key
input
- general improvements, such as parsing, default
- secret input
escape
unescape
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file revel-0.9.1.tar.gz
.
File metadata
- Download URL: revel-0.9.1.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.9-arch1-2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cfab62ef064627fc8579d85d1c552f269327290d8d2c55dd2b4b60b84afa380 |
|
MD5 | cc950ab156598bcd88f8bb37de46ba00 |
|
BLAKE2b-256 | 6c8a7403ea61e970794dc4de3ae340c9bad12e793b27d968d40f56856566992d |
File details
Details for the file revel-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: revel-0.9.1-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.9-arch1-2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70ec6e12ffd0ff2e8970b238a3d68090f7ffd3900ff1fc641a69bdb812dd3896 |
|
MD5 | 56832a4d4749d6dbaea7451c16342a93 |
|
BLAKE2b-256 | f0cce6df5839db27f832836b8987db184df52e7b66b5df3b5a031a68b3d82ba9 |