BottomBar
Bottombar is a Python module that facilitates printing a status line at the bottom of a terminal window. The module functions as a state machine, and allows multiple, individually submitted status items to be displayed simultaneously.
Requirements
A VT100-capable terminal is required. Most Linux terminals qualify, including Xterm, Rxvt, Gnome terminal, Kitty terminal, and Alacritty. On MS Windows the new Windows Terminal is recommended.
Other than this BottomBar has no dependencies beyond Python version 3.3.
How to use it
A bar entry is created using the module's add context, and displayed for the
duration that the context is entered. It also activates an event handler that
reformats and redraws the bar whenever the terminal window is resized.
>>> import bottombar as bb
>>>
>>> with bb.add('bottom bar', label='powered by') as item:
... print('regular output')
# regular output #
# powered by: bottom bar #
Items can be modified in place:
... item.text = 'bottom bar v2'
# powered by: bottom bar v2 #
Labels are optional, and multiple items can be stacked:
... with bb.add('more bar text'):
# regular output #
# powered by: bottom bar v2 | more bar text #
Items can be right-aligned:
... with bb.add('12:00', label='time', right=True):
# regular output #
# powered by: bottom bar v2 | more bar text time: 12:00 #
If items no longer fit the bar then labels are dropped to make room:
... with bb.add('more right-aligned bar text', right=True):
# regular output #
# bottom bar v2 | more bar text more right-aligned bar text | 12:00 #
If this is not enough, long text entries are truncated:
... with bb.add('this is getting too much'):
# regular output #
# bottom bar v2 | more bar text | this is gettin.. more right-ali.. | 12:00 #
The bar is automatically redrawn whenever its contents change. Content that changes dynamically can be refreshed at a configured rate:
>>> import time
>>> class Clock:
... def __str__(self):
... return time.strftime('%H:%M:%S')
>>> with bb.add(Clock(), label='time', right=True, refresh=1):
# time: 12:00:00 #
# time: 12:00:01 #
# time: 12:00:02 #
In case multiple refresh rates are configured simultaneously, the fastest rate prevails.
Technical details
The status line is positioned, and kept in position, using VT100 escape sequences. By configuring a scroll region that excludes the bottom line, regular output will scroll above it without further intervention.
The implementaton of automatic redrawing depends on the platform. On Unix-like
systems both resize events and the redraw rate are handled using signals:
SIGWINCH and SIGALRM. Pre-existing handlers for the former remain active,
while those for the latter are disabled for the duration that a bar is active.
On other platforms a thread is spawned that polls the terminal size once every
second, as well as redraws the bar at the configured interval.
Metadata
Release files for bottombar 2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bottombar-2.1.tar.gz | 7.6 kB | Without provenance | Details for bottombar-2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bottombar-2.1-py3-none-any.whl | Python 3 | none | any | Details for bottombar-2.1-py3-none-any.whl |
Total release size: 15.3 kB
Release files / bottombar-2.1.tar.gz
| Download URL | bottombar-2.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7611e7758f81380aa694d3c8fb1b7f9cb8d7328a9c0cf0f03a8caeb47bbcb299
|
|
BLAKE2b-256 checksum How to use checksums |
fef2dd7d2497643adc032275076fa51bc24d11e8799386600352cc073390287c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.25.1
|
Release files / bottombar-2.1-py3-none-any.whl
| Download URL | bottombar-2.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61cf3e5c6058d4c3b340ca89d86abaf41ea526ce129ae24a278347ddd346e1ee
|
|
BLAKE2b-256 checksum How to use checksums |
cebecf35ced83cfcae4cc1786bc3e2b4072d70cf86443d79a7ec2fad63bb2bff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.25.1
|
Security for bottombar 2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.