Package: bottombar
BottomBarBottombar 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.RequirementsA VT100-capable terminal is required. Most Linux terminals qualify, including
Xterm, Rxvt, Gnome terminal, Kitty terminal, and Alacritty. On MS Windows the
newWindows Terminalis recommended.Other than this BottomBar has no dependencies beyond Python version 3.3.How to use itA bar entry is created using the module'saddcontext, 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.>>>importbottombarasbb>>>>>>withbb.add('bottom bar',label='powered by')asitem:...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:...withbb.add('more bar text'):# regular output                                                              ## powered by: bottom bar v2 | more bar text                                   #Items can be right-aligned:...withbb.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:...withbb.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:...withbb.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:>>>importtime>>>classClock:...def__str__(self):...returntime.strftime('%H:%M:%S')>>>withbb.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 detailsThe status line is positioned, and kept in position, usingVT100 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:SIGWINCHandSIGALRM. 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.